pkgs/den-http-get-updater: allow to provide unpack and name argument per prefetch
This commit is contained in:
parent
517ca95d8d
commit
735a41ca0f
1 changed files with 10 additions and 5 deletions
|
@ -23,6 +23,8 @@
|
||||||
# };
|
# };
|
||||||
# prefetchHash: string?;
|
# prefetchHash: string?;
|
||||||
# targetHash: string?;
|
# targetHash: string?;
|
||||||
|
# unpack: bool?;
|
||||||
|
# name: string?;
|
||||||
# }[]
|
# }[]
|
||||||
#
|
#
|
||||||
prefetchList ? [],
|
prefetchList ? [],
|
||||||
|
@ -38,7 +40,6 @@
|
||||||
unpack ? true,
|
unpack ? true,
|
||||||
hashAlgo ? "sha256",
|
hashAlgo ? "sha256",
|
||||||
hashFormat ? "sri",
|
hashFormat ? "sri",
|
||||||
name ? if unpack then "source" else null,
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -52,7 +53,8 @@ let
|
||||||
);
|
);
|
||||||
assert lib.isAttrs x.prefetchUrlLocation && lib.isString x.prefetchUrlLocation.attrpath or null;
|
assert lib.isAttrs x.prefetchUrlLocation && lib.isString x.prefetchUrlLocation.attrpath or null;
|
||||||
rec {
|
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;
|
mark = builtins.hashString "sha256" x.previousHash;
|
||||||
markRegexEscape = lib.escapeRegex mark;
|
markRegexEscape = lib.escapeRegex mark;
|
||||||
realFileLocation = builtins.toString x.fileLocation or fileLocation;
|
realFileLocation = builtins.toString x.fileLocation or fileLocation;
|
||||||
|
@ -66,8 +68,6 @@ let
|
||||||
|
|
||||||
previousVersionRegexEscape = lib.escapeRegex previousVersion;
|
previousVersionRegexEscape = lib.escapeRegex previousVersion;
|
||||||
|
|
||||||
nixUnpack = lib.optionalString unpack "--unpack";
|
|
||||||
nixName = lib.optionalString (!builtins.isNull name) "--name \"${lib.escapeShellArg name}\"";
|
|
||||||
|
|
||||||
path = lib.makeBinPath ([
|
path = lib.makeBinPath ([
|
||||||
curl
|
curl
|
||||||
|
@ -104,10 +104,15 @@ writeScript "den-http-get-updater" (''
|
||||||
+ lib.concatStringsSep "\n" (lib.map ({
|
+ lib.concatStringsSep "\n" (lib.map ({
|
||||||
fileLocation,
|
fileLocation,
|
||||||
markRegexEscape,
|
markRegexEscape,
|
||||||
|
name,
|
||||||
prefetchUrlLocationShellEscape,
|
prefetchUrlLocationShellEscape,
|
||||||
realFileLocationShellEscape,
|
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 \
|
nixUrlsResult=$(nix-instantiate --eval --json --strict \
|
||||||
"${prefetchUrlLocationShellEscape.file}" \
|
"${prefetchUrlLocationShellEscape.file}" \
|
||||||
-A "${prefetchUrlLocationShellEscape.attrpath}"
|
-A "${prefetchUrlLocationShellEscape.attrpath}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue