2023-07-25 15:23:07 -07:00

47 lines
1.2 KiB
Nix

{ config, lib, pkgs, ... }:
let cfg = config.modules.services.samba-server;
in {
options.modules.services.samba-server.enable = lib.mkEnableOption "samba-server";
config = lib.mkIf cfg.enable {
services.samba = {
enable = true;
extraConfig = ''
workgroup = WORKGROUP
server string = smbnix
netbios name = smbnix
security = user
hosts allow = 192.168.1. 127.0.0.1 localhost
hosts deny = 0.0.0.0/0
guest account = nobody
map to guest = bad user
'';
shares = {
private = {
"path" = "/engi";
browseable = "yes";
"read only" = "no";
"guest ok" = "no";
"force user" = "tstarr";
"force group" = "users";
};
public = {
"path" = "/engi";
browseable = "yes";
"read only" = "yes";
"guest ok" = "yes";
};
};
};
# 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 ];
};
}