2021-12-05 21:28:49 +01:00
|
|
|
{ config, lib, options, pkgs, ... }:
|
2018-09-16 21:54:16 +02:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
name = "sickbeard";
|
|
|
|
|
|
|
|
cfg = config.services.sickbeard;
|
2021-12-05 21:28:49 +01:00
|
|
|
opt = options.services.sickbeard;
|
2018-09-16 21:54:16 +02:00
|
|
|
sickbeard = cfg.package;
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.sickbeard = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable the sickbeard server.";
|
|
|
|
};
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.sickbeard;
|
2021-10-03 18:06:03 +02:00
|
|
|
defaultText = literalExpression "pkgs.sickbeard";
|
|
|
|
example = literalExpression "pkgs.sickrage";
|
2018-09-16 21:54:16 +02:00
|
|
|
description =''
|
|
|
|
Enable <literal>pkgs.sickrage</literal> or <literal>pkgs.sickgear</literal>
|
|
|
|
as an alternative to SickBeard
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/${name}";
|
|
|
|
description = "Path where to store data files.";
|
|
|
|
};
|
|
|
|
configFile = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "${cfg.dataDir}/config.ini";
|
2021-12-05 21:28:49 +01:00
|
|
|
defaultText = literalExpression ''"''${config.${opt.dataDir}}/config.ini"'';
|
2018-09-16 21:54:16 +02:00
|
|
|
description = "Path to config file.";
|
|
|
|
};
|
|
|
|
port = mkOption {
|
|
|
|
type = types.ints.u16;
|
|
|
|
default = 8081;
|
|
|
|
description = "Port to bind to.";
|
|
|
|
};
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = name;
|
|
|
|
description = "User to run the service as";
|
|
|
|
};
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = name;
|
|
|
|
description = "Group to run the service as";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2019-09-14 19:51:29 +02:00
|
|
|
users.users = optionalAttrs (cfg.user == name) {
|
|
|
|
${name} = {
|
|
|
|
uid = config.ids.uids.sickbeard;
|
|
|
|
group = cfg.group;
|
|
|
|
description = "sickbeard user";
|
|
|
|
home = cfg.dataDir;
|
|
|
|
createHome = true;
|
|
|
|
};
|
|
|
|
};
|
2018-09-16 21:54:16 +02:00
|
|
|
|
2019-09-14 19:51:29 +02:00
|
|
|
users.groups = optionalAttrs (cfg.group == name) {
|
|
|
|
${name}.gid = config.ids.gids.sickbeard;
|
|
|
|
};
|
2018-09-16 21:54:16 +02:00
|
|
|
|
|
|
|
systemd.services.sickbeard = {
|
|
|
|
description = "Sickbeard Server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2021-10-15 07:00:36 +02:00
|
|
|
ExecStart = "${sickbeard}/bin/${sickbeard.pname} --datadir ${cfg.dataDir} --config ${cfg.configFile} --port ${toString cfg.port}";
|
2018-09-16 21:54:16 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|