1
0
mirror of https://github.com/tboerger/nixos-config synced 2024-11-22 18:21:58 +01:00
github.com-tboerger-nixos-c.../shared/services/shares.nix

142 lines
3.2 KiB
Nix
Raw Normal View History

2022-10-25 09:53:40 +02:00
{ pkgs, lib, config, options, ... }:
with lib;
let
2022-11-10 16:01:39 +01:00
cfg = config.personal.services.shares;
2022-10-25 09:53:40 +02:00
in
{
options = {
personal = {
services = {
2022-11-10 16:01:39 +01:00
shares = {
enable = mkEnableOption "Shares";
2022-10-25 09:53:40 +02:00
};
};
};
};
config = mkIf cfg.enable {
users = {
users = {
media = {
uid = 20000;
description = "Media";
shell = pkgs.zsh;
isSystemUser = true;
group = "media";
home = "/var/lib/media";
2024-07-17 16:05:33 +02:00
hashedPasswordFile = config.age.secrets."users/media/password".path;
2022-10-25 09:53:40 +02:00
};
printer = {
uid = 20001;
description = "Printer";
shell = pkgs.zsh;
isSystemUser = true;
group = "printer";
home = "/var/lib/printer";
2024-07-17 16:05:33 +02:00
hashedPasswordFile = config.age.secrets."users/printer/password".path;
2022-10-25 09:53:40 +02:00
};
};
groups = {
media = {
gid = 20000;
};
printer = {
gid = 20001;
};
};
};
services = {
samba = {
enable = true;
openFirewall = true;
securityType = "user";
2022-10-25 09:53:40 +02:00
extraConfig = ''
workgroup = WORKGROUP
2022-10-25 10:42:26 +02:00
server string = Server
netbios name = Server
2022-10-25 09:53:40 +02:00
guest account = nobody
map to guest = bad user
server min protocol = SMB2
2022-10-25 09:53:40 +02:00
'';
shares = {
2022-10-25 10:42:26 +02:00
shares = {
comment = "General shares";
2022-11-10 16:01:39 +01:00
path = "/var/lib/shares";
2022-10-25 10:42:26 +02:00
"browseable" = "yes";
"read only" = "no";
"writeable" = "yes";
"guest ok" = "yes";
"force user" = "media";
"force group" = "media";
};
2022-10-25 09:53:40 +02:00
photos = {
comment = "Shared photos";
2022-11-10 16:01:39 +01:00
path = "/var/lib/photos";
2022-10-25 09:53:40 +02:00
"browseable" = "yes";
"read only" = "no";
"writeable" = "yes";
"guest ok" = "yes";
"force user" = "media";
"force group" = "media";
};
videos = {
comment = "Shared videos";
2022-11-10 16:01:39 +01:00
path = "/var/lib/videos";
2022-10-25 09:53:40 +02:00
"browseable" = "yes";
"read only" = "no";
"writeable" = "yes";
"guest ok" = "yes";
"force user" = "media";
"force group" = "media";
};
printer = {
comment = "Shared printer";
path = "/var/lib/printer";
"browseable" = "yes";
"read only" = "no";
"writeable" = "yes";
"guest ok" = "yes";
"force user" = "printer";
"force group" = "printer";
};
backup = {
comment = "Shared backup";
path = "/var/lib/backup/%u";
"browseable" = "yes";
"read only" = "no";
"writeable" = "yes";
"guest ok" = "no";
};
};
};
2022-11-10 16:01:39 +01:00
samba-wsdd = {
enable = true;
};
2022-10-25 09:53:40 +02:00
};
2024-07-17 16:05:33 +02:00
age.secrets."users/media/password" = {
file = ../../secrets/users/media/password.age;
2022-10-25 09:53:40 +02:00
};
2024-07-17 16:05:33 +02:00
age.secrets."users/printer/password" = {
file = ../../secrets/users/printer/password.age;
2022-10-25 09:53:40 +02:00
};
};
}