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