about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2022-10-06 22:24:11 -0300
committerGitHub <noreply@github.com>2022-10-06 22:24:11 -0300
commit10c7f50248c588d51edb97b4fde99684d2916db3 (patch)
treef001ea66ccf3ac2c6a25e65b438dba85eae8882e /pkgs/build-support
parent76d36a9d65a1a7e9ad8b90387f3f6d9febe702aa (diff)
parent1fd6cf192a849c3ef9886ea34f7803991e8b127d (diff)
Merge pull request #194425 from SuperSandro2000/remove-double-fixed-output
Add support for pname+version to fetchzip/fetchurl
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/fetchurl/default.nix22
-rw-r--r--pkgs/build-support/fetchzip/default.nix17
2 files changed, 29 insertions, 10 deletions
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix
index a85d53adb8292..28d2519f4232c 100644
--- a/pkgs/build-support/fetchurl/default.nix
+++ b/pkgs/build-support/fetchurl/default.nix
@@ -57,6 +57,10 @@ in
   # first element of `urls').
   name ? ""
 
+  # for versioned downloads optionally take pname + version.
+, pname ? ""
+, version ? ""
+
 , # SRI hash.
   hash ? ""
 
@@ -130,12 +134,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 +185,4 @@ stdenvNoCC.mkDerivation {
 
   inherit meta;
   passthru = { inherit url; } // passthru;
-}
+})
diff --git a/pkgs/build-support/fetchzip/default.nix b/pkgs/build-support/fetchzip/default.nix
index 10142134792f5..9c08276cdb9b5 100644
--- a/pkgs/build-support/fetchzip/default.nix
+++ b/pkgs/build-support/fetchzip/default.nix
@@ -14,6 +14,8 @@
 , extraPostFetch ? ""
 , postFetch ? ""
 , name ? "source"
+, pname ? ""
+, version ? ""
 , nativeBuildInputs ? [ ]
 , # Allows to set the extension for the intermediate downloaded
   # file. This can be used as a hint for the unpackCmdHooks to select
@@ -23,14 +25,23 @@
 
 
 lib.warnIf (extraPostFetch != "") "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub'."
-(fetchurl (let
+
+(let
   tmpFilename =
     if extension != null
     then "download.${extension}"
     else baseNameOf (if url != "" then url else builtins.head urls);
-in {
-  inherit name;
+in
 
+fetchurl ((
+  if (pname != "" && version != "") then
+    {
+      name = "${name}-${version}";
+      inherit pname version;
+    }
+  else
+    { inherit name; }
+) // {
   recursiveHash = true;
 
   downloadToTemp = true;