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