2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-07-03 16:10:48 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2010-07-03 16:10:48 +01:00
|
|
|
|
2011-09-14 19:20:50 +01:00
|
|
|
let
|
2010-07-03 16:10:48 +01:00
|
|
|
|
|
|
|
cfg = config.services.sabnzbd;
|
|
|
|
inherit (pkgs) sabnzbd;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.sabnzbd = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
2015-05-01 20:38:00 +01:00
|
|
|
description = "Whether to enable the sabnzbd server.";
|
2010-07-03 16:10:48 +01:00
|
|
|
};
|
|
|
|
configFile = mkOption {
|
2015-05-01 20:38:00 +01:00
|
|
|
default = "/var/lib/sabnzbd/sabnzbd.ini";
|
|
|
|
description = "Path to config file.";
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
default = "sabnzbd";
|
|
|
|
description = "User to run the service as";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
default = "sabnzbd";
|
|
|
|
description = "Group to run the service as";
|
2010-07-03 16:10:48 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-07-03 16:10:48 +01:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.users.sabnzbd = {
|
2010-07-03 16:10:48 +01:00
|
|
|
uid = config.ids.uids.sabnzbd;
|
2015-05-01 20:38:00 +01:00
|
|
|
group = "sabnzbd";
|
2010-07-03 16:10:48 +01:00
|
|
|
description = "sabnzbd user";
|
2015-05-01 20:38:00 +01:00
|
|
|
home = "/var/lib/sabnzbd/";
|
|
|
|
createHome = true;
|
|
|
|
};
|
2010-07-03 16:10:48 +01:00
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.groups.sabnzbd = {
|
2015-05-01 20:38:00 +01:00
|
|
|
gid = config.ids.gids.sabnzbd;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.sabnzbd = {
|
|
|
|
description = "sabnzbd server";
|
2014-09-22 12:09:53 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
2015-05-01 20:38:00 +01:00
|
|
|
GuessMainPID = "no";
|
|
|
|
User = "${cfg.user}";
|
|
|
|
Group = "${cfg.group}";
|
2014-09-22 12:09:53 +01:00
|
|
|
ExecStart = "${sabnzbd}/bin/sabnzbd -d -f ${cfg.configFile}";
|
|
|
|
};
|
2015-05-01 20:38:00 +01:00
|
|
|
};
|
2010-07-03 16:10:48 +01:00
|
|
|
};
|
|
|
|
}
|