Created
July 4, 2020 04:16
-
-
Save vy-let/a030c1079f09ecae4135aebf1e121ea6 to your computer and use it in GitHub Desktop.
Setting up NixOS for typical home SMB file sharing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
{ | |
services.samba = { | |
enable = true; | |
syncPasswordsByPam = true; | |
# You will still need to set up the user accounts to begin with: | |
# $ sudo smbpasswd -a yourusername | |
# This adds to the [global] section: | |
extraConfig = '' | |
browseable = yes | |
smb encrypt = required | |
''; | |
shares = { | |
homes = { | |
browseable = "no"; # note: each home will be browseable; the "homes" share will not. | |
"read only" = "no"; | |
"guest ok" = "no"; | |
}; | |
}; | |
}; | |
# Curiously, `services.samba` does not automatically open | |
# the needed ports in the firewall. | |
networking.firewall.allowedTCPPorts = [ 445 139 ]; | |
networking.firewall.allowedUDPPorts = [ 137 138 ]; | |
# To make SMB mounting easier on the command line | |
environment.systemPackages = with pkgs; [ | |
cifs-utils | |
]; | |
# mDNS | |
# | |
# This part may be optional for your needs, but I find it makes browsing in Dolphin easier, | |
# and it makes connecting from a local Mac possible. | |
services.avahi = { | |
enable = true; | |
nssmdns = true; | |
publish = { | |
enable = true; | |
addresses = true; | |
domain = true; | |
hinfo = true; | |
userServices = true; | |
workstation = true; | |
}; | |
extraServiceFiles = { | |
smb = '' | |
<?xml version="1.0" standalone='no'?><!--*-nxml-*--> | |
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"> | |
<service-group> | |
<name replace-wildcards="yes">%h</name> | |
<service> | |
<type>_smb._tcp</type> | |
<port>445</port> | |
</service> | |
</service-group> | |
''; | |
}; | |
}; | |
} |
Glad I could help!
Regarding nssmdns4
, I believe the issue is with the version - I'm running my server on nixos-unstable
, and when I used nssmdns
alone it threw a warning saying that option was renamed recently - I believe it's because nssmdns4
is for ipv4 only, and it was renamed for clarity.
@ddanon Thanks your solution worked well.
For anyone else having trouble, here's what I did:
- skipped the extra config portion
- Don't forget to setup
sudo smbpasswd -a <user>
to add a user. Also add a password to the user when prompted
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested and working with the minor modifications below for those not using flakes. Thanks for the update @TheRealGramdalf! You saved me a bunch of time.
The only glaring difference is that I got
nssmdns4
does not exist so I commented it out.