fetchurl: add pname+version support

This commit is contained in:
Sandro Jäckel 2022-10-04 17:30:06 +02:00
parent fc95752d6f
commit 7deac8b8f7
No known key found for this signature in database
GPG Key ID: B1763F8651144063

View File

@ -57,6 +57,11 @@ in
# first element of `urls').
name ? ""
# for versioned downloads optionally take pname + version.
# if name is set that is preferred
, pname ? ""
, version ? ""
, # SRI hash.
hash ? ""
@ -130,12 +135,16 @@ let
else throw "fetchurl requires a hash for fixed-output derivation: ${lib.concatStringsSep ", " urls_}";
in
stdenvNoCC.mkDerivation {
name =
if showURLs then "urls"
else if name != "" then name
else baseNameOf (toString (builtins.head urls_));
stdenvNoCC.mkDerivation ((
if (pname != "" && version != "") then
{ inherit pname version; }
else
{ name =
if showURLs then "urls"
else if name != "" then name
else baseNameOf (toString (builtins.head urls_));
}
) // {
builder = ./builder.sh;
nativeBuildInputs = [ curl ] ++ nativeBuildInputs;
@ -177,4 +186,4 @@ stdenvNoCC.mkDerivation {
inherit meta;
passthru = { inherit url; } // passthru;
}
})