Skip to content

Commit

Permalink
nixos/nzbget: add option to override package (NixOS#302204)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrumplex authored Nov 9, 2024
2 parents f8bb0b8 + be97874 commit 8c2c5fa
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions nixos/modules/services/misc/nzbget.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ config, pkgs, lib, ... }:
let
cfg = config.services.nzbget;
pkg = pkgs.nzbget;
stateDir = "/var/lib/nzbget";
configFile = "${stateDir}/nzbget.conf";
configOpts = lib.concatStringsSep " " (lib.mapAttrsToList (name: value: "-o ${name}=${lib.escapeShellArg (toStr value)}") cfg.settings);
Expand All @@ -24,6 +23,8 @@ in
services.nzbget = {
enable = lib.mkEnableOption "NZBGet, for downloading files from news servers";

package = lib.mkPackageOption pkgs "nzbget" { };

user = lib.mkOption {
type = lib.types.str;
default = "nzbget";
Expand Down Expand Up @@ -64,8 +65,8 @@ in
InfoTarget = "screen";
DetailTarget = "screen";
# required paths
ConfigTemplate = "${pkg}/share/nzbget/nzbget.conf";
WebDir = "${pkg}/share/nzbget/webui";
ConfigTemplate = "${cfg.package}/share/nzbget/nzbget.conf";
WebDir = "${cfg.package}/share/nzbget/webui";
# nixos handles package updates
UpdateCheck = "none";
};
Expand All @@ -81,7 +82,7 @@ in

preStart = ''
if [ ! -f ${configFile} ]; then
${pkgs.coreutils}/bin/install -m 0700 ${pkg}/share/nzbget/nzbget.conf ${configFile}
${pkgs.coreutils}/bin/install -m 0700 ${cfg.package}/share/nzbget/nzbget.conf ${configFile}
fi
'';

Expand All @@ -92,8 +93,8 @@ in
Group = cfg.group;
UMask = "0002";
Restart = "on-failure";
ExecStart = "${pkg}/bin/nzbget --server --configfile ${stateDir}/nzbget.conf ${configOpts}";
ExecStop = "${pkg}/bin/nzbget --quit";
ExecStart = "${cfg.package}/bin/nzbget --server --configfile ${stateDir}/nzbget.conf ${configOpts}";
ExecStop = "${cfg.package}/bin/nzbget --quit";
};
};

Expand Down

0 comments on commit 8c2c5fa

Please sign in to comment.