2018-07-20 20:56:59 +00: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 = {
|
2023-10-18 12:08:30 +00:00
|
|
|
enable = mkEnableOption "Radarr, a UsetNet/BitTorrent movie downloader";
|
2019-02-19 19:25:58 +00:00
|
|
|
|
2023-11-27 00:19:27 +00:00
|
|
|
package = mkPackageOption pkgs "radarr" { };
|
2022-04-10 13:40:54 +00:00
|
|
|
|
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 {
|
2024-01-11 21:10:18 +00:00
|
|
|
systemd.tmpfiles.settings."10-radarr".${cfg.dataDir}.d = {
|
|
|
|
inherit (cfg) user group;
|
|
|
|
mode = "0700";
|
|
|
|
};
|
2019-02-23 22:51:07 +00:00
|
|
|
|
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;
|
2022-04-10 13:40:54 +00:00
|
|
|
ExecStart = "${cfg.package}/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
|
|
|
};
|
|
|
|
}
|