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
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.lidarr;
|
|
|
|
defaultText = "pkgs.lidarr";
|
|
|
|
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 {
|
|
|
|
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-06-24 10:53:38 +02:00
|
|
|
ExecStart = "${cfg.package}/bin/Lidarr";
|
2018-09-09 12:10:04 +02:00
|
|
|
Restart = "on-failure";
|
|
|
|
|
2019-02-24 18:36:50 +01:00
|
|
|
StateDirectory = "lidarr";
|
2018-09-09 12:10:04 +02:00
|
|
|
StateDirectoryMode = "0770";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|