diff --git a/modules/hosts/nixberry/default.nix b/modules/hosts/nixberry/default.nix index d5c2d2f..2e766bc 100644 --- a/modules/hosts/nixberry/default.nix +++ b/modules/hosts/nixberry/default.nix @@ -8,7 +8,6 @@ topLevel: { ... }: let - ipAddress = "192.168.178.2"; sopsFile = ../../../secrets/secrets-nixberry.yaml; in @@ -287,72 +286,5 @@ topLevel: { }; openFirewall = true; }; - - sops.secrets = { - "samba/cholli" = { - sopsFile = ../../../secrets/secrets.yaml; - }; - }; - - services = { - samba = { - enable = true; - openFirewall = true; - - settings = { - global = { - "smb3 unix extensions" = "yes"; - }; - - cholli = { - path = "/storage/cholli"; - browsable = "yes"; - writable = "yes"; - "create mask" = "0664"; - "directory mask" = "0775"; - "force group" = "users"; - }; - - kaman = { - path = "/storage/kaman"; - browsable = "yes"; - writable = "yes"; - "create mask" = "0664"; - "directory mask" = "0775"; - "force group" = "users"; - }; - - }; - - }; - - avahi.enable = true; - samba-wsdd = { - enable = true; - openFirewall = true; - }; - }; - - # add user passwords - systemd.services.samba-smbd.postStart = - let - users = [ - "cholli" - ]; - setupUser = - user: - let - passwordPath = config.sops.secrets."samba/${user}".path; - smbpasswd = "${config.services.samba.package}/bin/smbpasswd"; - in - '' - (echo $(< ${passwordPath}); - echo $(< ${passwordPath})) | \ - ${smbpasswd} -s -a ${user} - ''; - in - '' - ${builtins.concatStringsSep "\n" (map setupUser users)} - ''; }; } diff --git a/modules/hosts/nixberry/samba.nix b/modules/hosts/nixberry/samba.nix new file mode 100644 index 0000000..9c91fdd --- /dev/null +++ b/modules/hosts/nixberry/samba.nix @@ -0,0 +1,73 @@ +{ + flake.modules.nixos."hosts/nixberry" = + { config, ... }: + { + + sops.secrets = { + "samba/cholli" = { + sopsFile = ../../../secrets/secrets.yaml; + }; + }; + + services = { + samba = { + enable = true; + openFirewall = true; + + settings = { + global = { + "smb3 unix extensions" = "yes"; + }; + + cholli = { + path = "/storage/cholli"; + browsable = "yes"; + writable = "yes"; + "create mask" = "0664"; + "directory mask" = "0775"; + "force group" = "users"; + }; + + kaman = { + path = "/storage/kaman"; + browsable = "yes"; + writable = "yes"; + "create mask" = "0664"; + "directory mask" = "0775"; + "force group" = "users"; + }; + + }; + + }; + + avahi.enable = true; + samba-wsdd = { + enable = true; + openFirewall = true; + }; + }; + + # add user passwords + systemd.services.samba-smbd.postStart = + let + users = [ + "cholli" + ]; + setupUser = + user: + let + passwordPath = config.sops.secrets."samba/${user}".path; + smbpasswd = "${config.services.samba.package}/bin/smbpasswd"; + in + '' + (echo $(< ${passwordPath}); + echo $(< ${passwordPath})) | \ + ${smbpasswd} -s -a ${user} + ''; + in + '' + ${builtins.concatStringsSep "\n" (map setupUser users)} + ''; + }; +}