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 = {
|
2020-04-20 19:05:26 +01:00
|
|
|
enable = mkEnableOption "the sabnzbd server";
|
|
|
|
|
2021-11-20 04:01:24 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.sabnzbd;
|
|
|
|
defaultText = "pkgs.sabnzbd";
|
|
|
|
description = "The sabnzbd executable package run by the service.";
|
|
|
|
};
|
|
|
|
|
2010-07-03 16:10:48 +01:00
|
|
|
configFile = mkOption {
|
2021-01-31 11:12:59 +00:00
|
|
|
type = types.path;
|
2015-05-01 20:38:00 +01:00
|
|
|
default = "/var/lib/sabnzbd/sabnzbd.ini";
|
|
|
|
description = "Path to config file.";
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
default = "sabnzbd";
|
2021-01-31 11:12:59 +00:00
|
|
|
type = types.str;
|
2015-05-01 20:38:00 +01:00
|
|
|
description = "User to run the service as";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
2021-01-31 11:12:59 +00:00
|
|
|
type = types.str;
|
2015-05-01 20:38:00 +01:00
|
|
|
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}";
|
2021-11-20 04:01:24 +00:00
|
|
|
ExecStart = "${lib.getBin cfg.package}/bin/sabnzbd -d -f ${cfg.configFile}";
|
2014-09-22 12:09:53 +01:00
|
|
|
};
|
2015-05-01 20:38:00 +01:00
|
|
|
};
|
2010-07-03 16:10:48 +01:00
|
|
|
};
|
|
|
|
}
|