nix-dotfiles/services/smb.nix

90 lines
1.9 KiB
Nix
Raw Normal View History

2024-04-07 16:34:42 +02:00
{ config, pkgs, lib, ... }:
{
services.samba = {
2024-04-10 17:18:31 +02:00
package = pkgs.samba4Full;
2024-04-07 16:34:42 +02:00
enable = true;
securityType = "user";
openFirewall = true;
extraConfig = ''
2024-04-10 17:00:40 +02:00
workgroup = WORKGROUP
2024-04-10 16:46:02 +02:00
server string = galadriel
netbios name = galadriel
2024-04-07 16:34:42 +02:00
security = user
#use sendfile = yes
#max protocol = smb2
2024-04-10 17:18:31 +02:00
min protocol = SMB3_00
server smb encrypt = required
2024-04-07 16:34:42 +02:00
# note: localhost is the ipv6 localhost ::1
2024-04-12 11:41:33 +02:00
hosts allow = 192.168.1. 192.168.0. 127.0.0.1 localhost 100.0.0.0/255.0.0.0
2024-04-10 16:46:02 +02:00
hosts deny = 0.0.0.0/0
2024-04-12 11:41:33 +02:00
guest account = nobody
2024-04-07 16:34:42 +02:00
map to guest = bad user
'';
shares = {
# public = {
# path = "/mnt/Shares/Public";
# browseable = "yes";
# "read only" = "no";
# "guest ok" = "yes";
# "create mask" = "0644";
# "directory mask" = "0755";
# "force user" = "username";
# "force group" = "groupname";
# };
2024-04-10 16:46:02 +02:00
Backup = {
path = "/Main/Backup";
2024-04-12 11:41:33 +02:00
browseable = "yes";
2024-04-07 16:34:42 +02:00
"force user" = "gunalx";
"force group" = "gunalx";
"read only" = "no";
2024-04-12 11:41:33 +02:00
"guest ok" = "no";
"create mask" = "0644";
"directory mask" = "0755";
2024-04-07 16:34:42 +02:00
};
};
};
services.samba-wsdd = {
enable = true;
openFirewall = true;
};
#networking.firewall.enable = true;
networking.firewall.allowPing = true;
2024-04-10 17:21:47 +02:00
#services.avahi.openfirewall = true;
2024-04-10 17:18:31 +02:00
services.avahi = {
enable = true;
nssmdns = true;
2024-04-10 17:21:11 +02:00
#nssmdns4 = true;
2024-04-10 17:18:31 +02:00
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>
'';
};
};
2024-04-07 16:34:42 +02:00
}