From e8a9775a6167736009a3bd255c8db7a56cfadb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Holl=C3=BD?= <1708197+j2ghz@users.noreply.github.com> Date: Sun, 7 Apr 2024 00:32:30 +0200 Subject: [PATCH 1/3] nixos/nzbget: add option to override package --- nixos/modules/services/misc/nzbget.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/nzbget.nix b/nixos/modules/services/misc/nzbget.nix index d02fda62fa4fa..6b1dc8a159d86 100644 --- a/nixos/modules/services/misc/nzbget.nix +++ b/nixos/modules/services/misc/nzbget.nix @@ -4,7 +4,7 @@ with lib; let cfg = config.services.nzbget; - pkg = pkgs.nzbget; + pkg = cfg.package; stateDir = "/var/lib/nzbget"; configFile = "${stateDir}/nzbget.conf"; configOpts = concatStringsSep " " (mapAttrsToList (name: value: "-o ${name}=${escapeShellArg (toStr value)}") cfg.settings); @@ -51,6 +51,8 @@ in MainDir = "/data"; }; }; + + package = mkPackageOption pkgs "nzbget" { }; }; }; From a96dce89d04813c5cce8eb967cc2dd3640aa016c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Holl=C3=BD?= <1708197+j2ghz@users.noreply.github.com> Date: Sat, 9 Nov 2024 13:06:56 +0100 Subject: [PATCH 2/3] PR feedback: Replace pkg variable, move package statement --- nixos/modules/services/misc/nzbget.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/misc/nzbget.nix b/nixos/modules/services/misc/nzbget.nix index 6b1dc8a159d86..c3e354550e9b1 100644 --- a/nixos/modules/services/misc/nzbget.nix +++ b/nixos/modules/services/misc/nzbget.nix @@ -4,7 +4,6 @@ with lib; let cfg = config.services.nzbget; - pkg = cfg.package; stateDir = "/var/lib/nzbget"; configFile = "${stateDir}/nzbget.conf"; configOpts = concatStringsSep " " (mapAttrsToList (name: value: "-o ${name}=${escapeShellArg (toStr value)}") cfg.settings); @@ -27,6 +26,8 @@ in services.nzbget = { enable = mkEnableOption (lib.mdDoc "NZBGet"); + package = mkPackageOption pkgs "nzbget" { }; + user = mkOption { type = types.str; default = "nzbget"; @@ -51,8 +52,6 @@ in MainDir = "/data"; }; }; - - package = mkPackageOption pkgs "nzbget" { }; }; }; @@ -69,8 +68,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"; }; @@ -86,7 +85,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 ''; @@ -97,8 +96,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"; }; }; From be978743512b3c1e7ac995cbad64cc634cd72d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Holl=C3=BD?= <1708197+j2ghz@users.noreply.github.com> Date: Sat, 9 Nov 2024 13:09:08 +0100 Subject: [PATCH 3/3] Fix: use lib.mkPackageOption --- nixos/modules/services/misc/nzbget.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/nzbget.nix b/nixos/modules/services/misc/nzbget.nix index ce2678913f729..4738baf6d3e5c 100644 --- a/nixos/modules/services/misc/nzbget.nix +++ b/nixos/modules/services/misc/nzbget.nix @@ -23,7 +23,7 @@ in services.nzbget = { enable = lib.mkEnableOption "NZBGet, for downloading files from news servers"; - package = mkPackageOption pkgs "nzbget" { }; + package = lib.mkPackageOption pkgs "nzbget" { }; user = lib.mkOption { type = lib.types.str;