2018-07-20 21:56:59 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2017-03-25 20:18:34 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.radarr;
|
2019-02-19 19:25:58 +00:00
|
|
|
|
2017-03-25 20:18:34 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.radarr = {
|
|
|
|
enable = mkEnableOption "Radarr";
|
2019-02-19 19:25:58 +00:00
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/radarr/.config/Radarr";
|
|
|
|
description = "The directory where Radarr stores its data files.";
|
|
|
|
};
|
|
|
|
|
|
|
|
openFirewall = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Open ports in the firewall for the Radarr web interface.";
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "radarr";
|
|
|
|
description = "User account under which Radarr runs.";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "radarr";
|
|
|
|
description = "Group under which Radarr runs.";
|
|
|
|
};
|
2017-03-25 20:18:34 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-02-23 22:51:07 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -"
|
|
|
|
];
|
|
|
|
|
2017-03-25 20:18:34 +00:00
|
|
|
systemd.services.radarr = {
|
|
|
|
description = "Radarr";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
2019-02-19 19:25:58 +00:00
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
ExecStart = "${pkgs.radarr}/bin/Radarr -nobrowser -data='${cfg.dataDir}'";
|
2017-03-25 20:18:34 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-02-19 19:25:58 +00:00
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
|
|
allowedTCPPorts = [ 7878 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users = mkIf (cfg.user == "radarr") {
|
|
|
|
radarr = {
|
|
|
|
group = cfg.group;
|
|
|
|
home = cfg.dataDir;
|
|
|
|
uid = config.ids.uids.radarr;
|
|
|
|
};
|
2017-03-25 20:18:34 +00:00
|
|
|
};
|
|
|
|
|
2019-02-19 19:25:58 +00:00
|
|
|
users.groups = mkIf (cfg.group == "radarr") {
|
|
|
|
radarr.gid = config.ids.gids.radarr;
|
|
|
|
};
|
2017-03-25 20:18:34 +00:00
|
|
|
};
|
|
|
|
}
|