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 = {
|
2022-08-28 19:18:44 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "the sabnzbd server");
|
2020-04-20 18:05:26 +00:00
|
|
|
|
2021-11-20 04:01:24 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.sabnzbd;
|
2022-11-03 14:52:19 +00:00
|
|
|
defaultText = lib.literalExpression "pkgs.sabnzbd";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "The sabnzbd executable package run by the service.";
|
2021-11-20 04:01:24 +00:00
|
|
|
};
|
|
|
|
|
2010-07-03 15:10:48 +00:00
|
|
|
configFile = mkOption {
|
2021-01-31 11:12:59 +00:00
|
|
|
type = types.path;
|
2015-05-01 19:38:00 +00:00
|
|
|
default = "/var/lib/sabnzbd/sabnzbd.ini";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Path to config file.";
|
2015-05-01 19:38:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
default = "sabnzbd";
|
2021-01-31 11:12:59 +00:00
|
|
|
type = types.str;
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "User to run the service as";
|
2015-05-01 19:38:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
2021-01-31 11:12:59 +00:00
|
|
|
type = types.str;
|
2015-05-01 19:38:00 +00:00
|
|
|
default = "sabnzbd";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "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 {
|
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.users.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
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.groups.sabnzbd = {
|
2015-05-01 19:38:00 +00:00
|
|
|
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}";
|
2021-11-20 04:01:24 +00:00
|
|
|
ExecStart = "${lib.getBin cfg.package}/bin/sabnzbd -d -f ${cfg.configFile}";
|
2014-09-22 11:09:53 +00:00
|
|
|
};
|
2015-05-01 19:38:00 +00:00
|
|
|
};
|
2010-07-03 15:10:48 +00:00
|
|
|
};
|
|
|
|
}
|