fetchurl: add pname+version support

+16 -7
+16 -7
pkgs/build-support/fetchurl/default.nix
··· 57 # first element of `urls'). 58 name ? "" 59 60 , # SRI hash. 61 hash ? "" 62 ··· 130 else throw "fetchurl requires a hash for fixed-output derivation: ${lib.concatStringsSep ", " urls_}"; 131 in 132 133 - stdenvNoCC.mkDerivation { 134 - name = 135 - if showURLs then "urls" 136 - else if name != "" then name 137 - else baseNameOf (toString (builtins.head urls_)); 138 - 139 builder = ./builder.sh; 140 141 nativeBuildInputs = [ curl ] ++ nativeBuildInputs; ··· 177 178 inherit meta; 179 passthru = { inherit url; } // passthru; 180 - }
··· 57 # first element of `urls'). 58 name ? "" 59 60 + # for versioned downloads optionally take pname + version. 61 + # if name is set that is preferred 62 + , pname ? "" 63 + , version ? "" 64 + 65 , # SRI hash. 66 hash ? "" 67 ··· 135 else throw "fetchurl requires a hash for fixed-output derivation: ${lib.concatStringsSep ", " urls_}"; 136 in 137 138 + stdenvNoCC.mkDerivation (( 139 + if (pname != "" && version != "") then 140 + { inherit pname version; } 141 + else 142 + { name = 143 + if showURLs then "urls" 144 + else if name != "" then name 145 + else baseNameOf (toString (builtins.head urls_)); 146 + } 147 + ) // { 148 builder = ./builder.sh; 149 150 nativeBuildInputs = [ curl ] ++ nativeBuildInputs; ··· 186 187 inherit meta; 188 passthru = { inherit url; } // passthru; 189 + })