From 735a41ca0fd13a2b32e6c14a356163c05351193d Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Mon, 7 Apr 2025 21:42:19 +0200 Subject: [PATCH] pkgs/den-http-get-updater: allow to provide unpack and name argument per prefetch --- pkgs/by-name/de/den-http-get-updater/package.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/de/den-http-get-updater/package.nix b/pkgs/by-name/de/den-http-get-updater/package.nix index b6ba547..484fa35 100644 --- a/pkgs/by-name/de/den-http-get-updater/package.nix +++ b/pkgs/by-name/de/den-http-get-updater/package.nix @@ -23,6 +23,8 @@ # }; # prefetchHash: string?; # targetHash: string?; + # unpack: bool?; + # name: string?; # }[] # prefetchList ? [], @@ -38,7 +40,6 @@ unpack ? true, hashAlgo ? "sha256", hashFormat ? "sri", - name ? if unpack then "source" else null, }: let @@ -52,7 +53,8 @@ let ); assert lib.isAttrs x.prefetchUrlLocation && lib.isString x.prefetchUrlLocation.attrpath or null; rec { - inherit fileLocation hashAlgo hashFormat; + inherit fileLocation hashAlgo hashFormat unpack; + name = if x.unpack or unpack then "source" else null; mark = builtins.hashString "sha256" x.previousHash; markRegexEscape = lib.escapeRegex mark; realFileLocation = builtins.toString x.fileLocation or fileLocation; @@ -66,8 +68,6 @@ let previousVersionRegexEscape = lib.escapeRegex previousVersion; - nixUnpack = lib.optionalString unpack "--unpack"; - nixName = lib.optionalString (!builtins.isNull name) "--name \"${lib.escapeShellArg name}\""; path = lib.makeBinPath ([ curl @@ -104,10 +104,15 @@ writeScript "den-http-get-updater" ('' + lib.concatStringsSep "\n" (lib.map ({ fileLocation, markRegexEscape, + name, prefetchUrlLocationShellEscape, realFileLocationShellEscape, + unpack, ... -}: '' +}: let + nixUnpack = lib.optionalString unpack "--unpack"; + nixName = lib.optionalString (!builtins.isNull name) "--name \"${lib.escapeShellArg name}\""; +in '' nixUrlsResult=$(nix-instantiate --eval --json --strict \ "${prefetchUrlLocationShellEscape.file}" \ -A "${prefetchUrlLocationShellEscape.attrpath}"