config/modules/services/jakstpub/default.nix

79 lines
1.9 KiB
Nix
Raw Normal View History

2023-09-12 13:31:46 +03:00
{
config,
lib,
pkgs,
2023-09-12 16:08:08 +03:00
myData,
2023-09-12 13:31:46 +03:00
...
}: {
options.mj.services.jakstpub = with lib.types; {
enable = lib.mkEnableOption "Enable jakstpub";
dataDir = lib.mkOption {type = path;};
# RequiresMountsFor is used by upstream, hacking with the unit
requires = lib.mkOption {type = listOf str;};
uidgid = lib.mkOption {type = int;};
2023-09-12 23:18:46 +03:00
hostname = lib.mkOption {type = str;};
2023-09-12 13:31:46 +03:00
};
config = with config.mj.services.jakstpub;
lib.mkIf enable {
services.samba = {
2023-09-12 22:55:17 +03:00
# https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Standalone_Server
2023-09-12 13:31:46 +03:00
enable = true;
securityType = "user";
enableNmbd = false;
enableWinbindd = false;
2023-09-12 13:31:46 +03:00
extraConfig = ''
map to guest = Bad User
2023-09-12 22:55:17 +03:00
guest account = jakstpub
server role = standalone server
2023-09-12 13:31:46 +03:00
'';
shares = {
public = {
path = dataDir;
2023-09-12 22:55:17 +03:00
writeable = "yes";
2023-09-12 13:31:46 +03:00
public = "yes";
2023-09-12 17:44:17 +03:00
"guest ok" = "yes";
"read only" = "no";
"create mask" = "0664";
"directory mask" = "0775";
2023-09-12 17:44:17 +03:00
"force user" = "jakstpub";
"force group" = "jakstpub";
2023-09-12 13:31:46 +03:00
};
};
};
2023-09-12 23:18:46 +03:00
services.samba-wsdd = {
enable = true;
hostname = hostname;
};
2023-09-12 13:31:46 +03:00
users.users.jakstpub = {
description = "Jakstys Public";
home = "/var/empty";
2023-09-12 13:31:46 +03:00
useDefaultShell = true;
group = "jakstpub";
isSystemUser = true;
createHome = false;
uid = uidgid;
};
users.groups.jakstpub.gid = uidgid;
systemd.services.samba-smbd = {
unitConfig.Requires = requires;
};
mj.services.friendlyport.ports = [
{
subnets = with myData.subnets; [tailscale.cidr vno1.cidr];
tcp = [
139 # smbd
445 # smbd
5357 # wsdd
];
udp = [3702]; # wsdd
}
];
2023-09-12 13:31:46 +03:00
};
}