diff options
author | Bruno BELANYI <bruno@belanyi.fr> | 2024-04-19 10:08:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-19 10:08:04 +0100 |
commit | 5d8f1c0172f424647e34f4e8eecb73fda30836aa (patch) | |
tree | cd38aa57de92298ee51f91ce18f60938356535d3 /nixos/modules/services/misc | |
parent | 8f659abb359ff9ae9177081916622888f5e181e1 (diff) | |
parent | 65251f102d3fd62cf267f592e09acf0ac0a31a1e (diff) |
Merge pull request #297805 from ambroisie/podgrab-user
nixos/podgrab: add user/group/dataDirectory options
Diffstat (limited to 'nixos/modules/services/misc')
-rw-r--r-- | nixos/modules/services/misc/podgrab.nix | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/nixos/modules/services/misc/podgrab.nix b/nixos/modules/services/misc/podgrab.nix index f95d2dc928cd..50dc70e2bd76 100644 --- a/nixos/modules/services/misc/podgrab.nix +++ b/nixos/modules/services/misc/podgrab.nix @@ -1,6 +1,8 @@ { config, lib, pkgs, ... }: let cfg = config.services.podgrab; + + stateDir = "/var/lib/podgrab"; in { options.services.podgrab = with lib; { @@ -22,28 +24,59 @@ in example = 4242; description = "The port on which Podgrab will listen for incoming HTTP traffic."; }; + + dataDirectory = mkOption { + type = types.path; + default = "${stateDir}/data"; + example = "/mnt/podcasts"; + description = "Directory to store downloads."; + }; + + user = mkOption { + type = types.str; + default = "podgrab"; + description = "User under which Podgrab runs, and which owns the download directory."; + }; + + group = mkOption { + type = types.str; + default = "podgrab"; + description = "Group under which Podgrab runs, and which owns the download directory."; + }; }; config = lib.mkIf cfg.enable { + systemd.tmpfiles.settings."10-pyload" = { + ${cfg.dataDirectory}.d = { inherit (cfg) user group; }; + }; + systemd.services.podgrab = { description = "Podgrab podcast manager"; wantedBy = [ "multi-user.target" ]; environment = { - CONFIG = "/var/lib/podgrab/config"; - DATA = "/var/lib/podgrab/data"; + CONFIG = "${stateDir}/config"; + DATA = cfg.dataDirectory; GIN_MODE = "release"; PORT = toString cfg.port; }; serviceConfig = { - DynamicUser = true; + User = cfg.user; + Group = cfg.group; EnvironmentFile = lib.optionals (cfg.passwordFile != null) [ cfg.passwordFile ]; ExecStart = "${pkgs.podgrab}/bin/podgrab"; WorkingDirectory = "${pkgs.podgrab}/share"; - StateDirectory = [ "podgrab/config" "podgrab/data" ]; + StateDirectory = [ "podgrab/config" ]; }; }; + + users.users.podgrab = lib.mkIf (cfg.user == "podgrab") { + isSystemUser = true; + group = cfg.group; + }; + + users.groups.podgrab = lib.mkIf (cfg.group == "podgrab") { }; }; meta.maintainers = with lib.maintainers; [ ambroisie ]; |