From c14f029dae7a6eba976549df6a787f9cbbfd444b Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 4 Feb 2024 13:29:46 +0000 Subject: nixos/pyload: add user/group options --- nixos/modules/services/networking/pyload.nix | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'nixos/modules') diff --git a/nixos/modules/services/networking/pyload.nix b/nixos/modules/services/networking/pyload.nix index f2b85499d4dd..93f8dd7d731a 100644 --- a/nixos/modules/services/networking/pyload.nix +++ b/nixos/modules/services/networking/pyload.nix @@ -34,6 +34,18 @@ in description = "Directory to store downloads."; }; + user = mkOption { + type = types.str; + default = "pyload"; + description = "User under which pyLoad runs, and which owns the download directory."; + }; + + group = mkOption { + type = types.str; + default = "pyload"; + description = "Group under which pyLoad runs, and which owns the download directory."; + }; + credentialsFile = mkOption { type = with types; nullOr path; default = null; @@ -52,7 +64,7 @@ in config = lib.mkIf cfg.enable { systemd.tmpfiles.settings.pyload = { - ${cfg.downloadDirectory}.d = { }; + ${cfg.downloadDirectory}.d = { inherit (cfg) user group; }; }; systemd.services.pyload = { @@ -80,9 +92,8 @@ in cfg.downloadDirectory ]; - User = "pyload"; - Group = "pyload"; - DynamicUser = true; + User = cfg.user; + Group = cfg.group; EnvironmentFile = lib.optional (cfg.credentialsFile != null) cfg.credentialsFile; @@ -143,5 +154,13 @@ in ]; }; }; + + users.users.pyload = lib.mkIf (cfg.user == "pyload") { + isSystemUser = true; + group = cfg.group; + home = stateDir; + }; + + users.groups.pyload = lib.mkIf (cfg.group == "pyload") { }; }; } -- cgit 1.4.1