2018-09-09 10:10:04 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.lidarr;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.lidarr = {
|
|
|
|
enable = mkEnableOption "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 = "The directory where Lidarr stores its data files.";
|
|
|
|
};
|
|
|
|
|
2019-06-24 08:53:38 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.lidarr;
|
|
|
|
defaultText = "pkgs.lidarr";
|
|
|
|
description = "The Lidarr package to use";
|
|
|
|
};
|
2019-07-01 15:15:27 +00: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 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
|
|
|
};
|
|
|
|
}
|