1 { config, pkgs, lib, ... }:
6 cfg = config.services.nzbget;
8 stateDir = "/var/lib/nzbget";
9 configFile = "${stateDir}/nzbget.conf";
10 configOpts = concatStringsSep " " (mapAttrsToList (name: value: "-o ${name}=${escapeShellArg (toStr value)}") cfg.settings);
12 if v == true then "yes"
13 else if v == false then "no"
14 else if isInt v then toString v
19 (mkRemovedOptionModule [ "services" "misc" "nzbget" "configFile" ] "The configuration of nzbget is now managed by users through the web interface.")
20 (mkRemovedOptionModule [ "services" "misc" "nzbget" "dataDir" ] "The data directory for nzbget is now /var/lib/nzbget.")
21 (mkRemovedOptionModule [ "services" "misc" "nzbget" "openFirewall" ] "The port used by nzbget is managed through the web interface so you should adjust your firewall rules accordingly.")
28 enable = mkEnableOption (lib.mdDoc "NZBGet");
33 description = lib.mdDoc "User account under which NZBGet runs";
39 description = lib.mdDoc "Group under which NZBGet runs";
43 type = with types; attrsOf (oneOf [ bool int str ]);
45 description = lib.mdDoc ''
46 NZBGet configuration, passed via command line using switch -o. Refer to
47 <https://github.com/nzbget/nzbget/blob/master/nzbget.conf>
48 for details on supported values.
59 config = mkIf cfg.enable {
60 services.nzbget.settings = {
61 # allows nzbget to run as a "simple" service
62 OutputMode = "loggable";
63 # use journald for logging
65 ErrorTarget = "screen";
66 WarningTarget = "screen";
67 InfoTarget = "screen";
68 DetailTarget = "screen";
70 ConfigTemplate = "${pkg}/share/nzbget/nzbget.conf";
71 WebDir = "${pkg}/share/nzbget/webui";
72 # nixos handles package updates
76 systemd.services.nzbget = {
77 description = "NZBGet Daemon";
78 after = [ "network.target" ];
79 wantedBy = [ "multi-user.target" ];
86 if [ ! -f ${configFile} ]; then
87 ${pkgs.coreutils}/bin/install -m 0700 ${pkg}/share/nzbget/nzbget.conf ${configFile}
92 StateDirectory = "nzbget";
93 StateDirectoryMode = "0750";
97 Restart = "on-failure";
98 ExecStart = "${pkg}/bin/nzbget --server --configfile ${stateDir}/nzbget.conf ${configOpts}";
99 ExecStop = "${pkg}/bin/nzbget --quit";
103 users.users = mkIf (cfg.user == "nzbget") {
107 uid = config.ids.uids.nzbget;
111 users.groups = mkIf (cfg.group == "nzbget") {
113 gid = config.ids.gids.nzbget;