{ 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" '' ${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;}); }; }