2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-07-03 15:10:48 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2010-07-03 15:10:48 +00:00
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
let
|
2010-07-03 15:10:48 +00:00
|
|
|
|
|
|
|
cfg = config.services.sabnzbd;
|
|
|
|
inherit (pkgs) sabnzbd;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.sabnzbd = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
2015-05-01 19:38:00 +00:00
|
|
|
description = "Whether to enable the sabnzbd server.";
|
2010-07-03 15:10:48 +00:00
|
|
|
};
|
|
|
|
configFile = mkOption {
|
2015-05-01 19:38:00 +00: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 15:10:48 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-07-03 15:10:48 +00:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2015-05-01 19:38:00 +00:00
|
|
|
users.extraUsers.sabnzbd = {
|
2010-07-03 15:10:48 +00:00
|
|
|
uid = config.ids.uids.sabnzbd;
|
2015-05-01 19:38:00 +00:00
|
|
|
group = "sabnzbd";
|
2010-07-03 15:10:48 +00:00
|
|
|
description = "sabnzbd user";
|
2015-05-01 19:38:00 +00:00
|
|
|
home = "/var/lib/sabnzbd/";
|
|
|
|
createHome = true;
|
|
|
|
};
|
2010-07-03 15:10:48 +00:00
|
|
|
|
2015-05-01 19:38:00 +00:00
|
|
|
users.extraGroups.sabnzbd = {
|
|
|
|
gid = config.ids.gids.sabnzbd;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.sabnzbd = {
|
|
|
|
description = "sabnzbd server";
|
2014-09-22 11:09:53 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
2015-05-01 19:38:00 +00:00
|
|
|
GuessMainPID = "no";
|
|
|
|
User = "${cfg.user}";
|
|
|
|
Group = "${cfg.group}";
|
2014-09-22 11:09:53 +00:00
|
|
|
ExecStart = "${sabnzbd}/bin/sabnzbd -d -f ${cfg.configFile}";
|
|
|
|
};
|
2015-05-01 19:38:00 +00:00
|
|
|
};
|
2010-07-03 15:10:48 +00:00
|
|
|
};
|
|
|
|
}
|