fetchurl: add pname+version support

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