-
-
Save alienzj/a83d8a81b84ab440809b4eb1a1233f82 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> | |
''; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment