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
|
|
|
|
|
|
|
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 {
|
|
|
|
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-06-24 08:53:38 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/Lidarr";
|
2018-09-09 10:10:04 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
|
2019-02-24 17:36:50 +00:00
|
|
|
StateDirectory = "lidarr";
|
2018-09-09 10:10:04 +00:00
|
|
|
StateDirectoryMode = "0770";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|