kubernetes-deployments/nixng-modules/radarr.nix

48 lines
1.2 KiB
Nix
Raw Permalink Normal View History

{
config,
lib,
nglib,
pkgs,
...
}: let
cfg = config.services.radarr;
cfgInit = config.init.services.radarr;
in {
options.services.radarr = {
enable = lib.mkEnableOption "radarr";
package = lib.mkPackageOption pkgs "radarr" {};
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/radarr/.config/Radarr";
description = "The directory where Radarr stores its data files.";
};
};
config = lib.mkIf cfg.enable {
init.services.radarr = {
enabled = true;
user = lib.mkDefault "radarr";
group = lib.mkDefault "radarr";
script = pkgs.writeShellScript "radarr-run.sh" ''
umask 0002
${lib.getExe cfg.package} -nobrowser -data='${cfg.dataDir}'
'';
};
environment.systemPackages = [cfg.package];
users.users.${cfgInit.user} = lib.mkIf (cfgInit.user == "radarr") (nglib.mkDefaultRec {
description = "radarr";
group = cfgInit.group;
createHome = false;
home = "/var/empty";
useDefaultShell = true;
uid = config.ids.uids.radarr;
});
users.groups.${cfgInit.group} = lib.mkIf (cfgInit.group == "radarr") (nglib.mkDefaultRec {gid = config.ids.gids.radarr;});
};
}