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