2018-09-09 12:10:04 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.lidarr;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.lidarr = {
|
|
|
|
enable = mkEnableOption "Lidarr";
|
2019-06-24 10:53:38 +02:00
|
|
|
|
2019-10-20 21:20:53 +02:00
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/lidarr/.config/Lidarr";
|
|
|
|
description = "The directory where Lidarr stores its data files.";
|
|
|
|
};
|
|
|
|
|
2019-06-24 10:53:38 +02:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.lidarr;
|
2021-10-03 18:06:03 +02:00
|
|
|
defaultText = literalExpression "pkgs.lidarr";
|
2019-06-24 10:53:38 +02:00
|
|
|
description = "The Lidarr package to use";
|
|
|
|
};
|
2019-07-01 17:15:27 +02:00
|
|
|
|
|
|
|
openFirewall = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Open ports in the firewall for Lidarr
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "lidarr";
|
|
|
|
description = ''
|
|
|
|
User account under which Lidarr runs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "lidarr";
|
|
|
|
description = ''
|
|
|
|
Group under which Lidarr runs.
|
|
|
|
'';
|
|
|
|
};
|
2018-09-09 12:10:04 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-10-20 21:20:53 +02:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -"
|
|
|
|
];
|
|
|
|
|
2018-09-09 12:10:04 +02:00
|
|
|
systemd.services.lidarr = {
|
|
|
|
description = "Lidarr";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
2019-07-01 17:15:27 +02:00
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2019-10-20 21:20:53 +02:00
|
|
|
ExecStart = "${cfg.package}/bin/Lidarr -nobrowser -data='${cfg.dataDir}'";
|
2018-09-09 12:10:04 +02:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-07-01 17:15:27 +02:00
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
|
|
allowedTCPPorts = [ 8686 ];
|
2018-09-09 12:10:04 +02:00
|
|
|
};
|
|
|
|
|
2019-07-01 17:15:27 +02:00
|
|
|
users.users = mkIf (cfg.user == "lidarr") {
|
|
|
|
lidarr = {
|
|
|
|
group = cfg.group;
|
2019-07-07 13:31:28 +02:00
|
|
|
home = "/var/lib/lidarr";
|
2019-07-01 17:15:27 +02:00
|
|
|
uid = config.ids.uids.lidarr;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups = mkIf (cfg.group == "lidarr") {
|
|
|
|
lidarr = {
|
|
|
|
gid = config.ids.gids.lidarr;
|
|
|
|
};
|
|
|
|
};
|
2018-09-09 12:10:04 +02:00
|
|
|
};
|
|
|
|
}
|