summary refs log tree commit diff
diff options
context:
space:
mode:
authorJan Malakhovski <oxij@oxij.org>2023-08-06 14:35:02 +0000
committerJan Malakhovski <oxij@oxij.org>2023-08-08 13:25:28 +0000
commit9dcecbdb3198fa8642dcaa56a0f845260bb7cfb5 (patch)
tree58f4df2c55dc3ee821769756790f36052362cbb6
parent672efa6939a6d569abc730339cc1efa700b91848 (diff)
downloadnixpkgs-9dcecbdb3198fa8642dcaa56a0f845260bb7cfb5.tar
nixpkgs-9dcecbdb3198fa8642dcaa56a0f845260bb7cfb5.tar.gz
nixpkgs-9dcecbdb3198fa8642dcaa56a0f845260bb7cfb5.tar.bz2
nixpkgs-9dcecbdb3198fa8642dcaa56a0f845260bb7cfb5.tar.lz
nixpkgs-9dcecbdb3198fa8642dcaa56a0f845260bb7cfb5.tar.xz
nixpkgs-9dcecbdb3198fa8642dcaa56a0f845260bb7cfb5.tar.zst
nixpkgs-9dcecbdb3198fa8642dcaa56a0f845260bb7cfb5.zip
fetchzip: cleanup and improve metrics a bit
-rw-r--r--pkgs/build-support/fetchzip/default.nix55
1 files changed, 21 insertions, 34 deletions
diff --git a/pkgs/build-support/fetchzip/default.nix b/pkgs/build-support/fetchzip/default.nix
index e980f9d6521..0446851d640 100644
--- a/pkgs/build-support/fetchzip/default.nix
+++ b/pkgs/build-support/fetchzip/default.nix
@@ -7,41 +7,34 @@
 
 { lib, fetchurl, unzip, glibcLocalesUtf8 }:
 
-{ # Optionally move the contents of the unpacked tree up one level.
-  stripRoot ? true
+{ name ? "source"
 , url ? ""
 , urls ? []
-, extraPostFetch ? ""
+, nativeBuildInputs ? []
 , 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
-  # an appropriate unpacking tool.
-  extension ? null
-, ... } @ args:
+, extraPostFetch ? ""
 
+# Optionally move the contents of the unpacked tree up one level.
+, stripRoot ? true
+# Allows to set the extension for the intermediate downloaded
+# file. This can be used as a hint for the unpackCmdHooks to select
+# an appropriate unpacking tool.
+, extension ? null
+
+# the rest are given to fetchurl as is
+, ... } @ args:
 
-lib.warnIf (extraPostFetch != "") "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub'."
+assert (extraPostFetch != "") -> lib.warn "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub'." true;
 
-(let
+let
   tmpFilename =
     if extension != null
     then "download.${extension}"
     else baseNameOf (if url != "" then url else builtins.head urls);
 in
 
-fetchurl ((
-  if (pname != "" && version != "") then
-    {
-      name = "${pname}-${version}";
-      inherit pname version;
-    }
-  else
-    { inherit name; }
-) // {
+fetchurl ({
+  inherit name;
   recursiveHash = true;
 
   downloadToTemp = true;
@@ -61,8 +54,7 @@ fetchurl ((
       mv "$downloadedFile" "$renamed"
       unpackFile "$renamed"
       chmod -R +w "$unpackDir"
-    ''
-    + (if stripRoot then ''
+    '' + (if stripRoot then ''
       if [ $(ls -A "$unpackDir" | wc -l) != 1 ]; then
         echo "error: zip file must contain a single file or directory."
         echo "hint: Pass stripRoot=false; to fetchzip to assume flat list of files."
@@ -75,16 +67,11 @@ fetchurl ((
       mv "$unpackDir/$fn" "$out"
     '' else ''
       mv "$unpackDir" "$out"
-    '')
-    + ''
+    '') + ''
       ${postFetch}
-    '' + ''
       ${extraPostFetch}
-    ''
-
-    # Remove non-owner write permissions
-    # Fixes https://github.com/NixOS/nixpkgs/issues/38649
-    + ''
       chmod 755 "$out"
     '';
-} // removeAttrs args [ "stripRoot" "extraPostFetch" "postFetch" "extension" "nativeBuildInputs" ]))
+    # ^ Remove non-owner write permissions
+    # Fixes https://github.com/NixOS/nixpkgs/issues/38649
+} // removeAttrs args [ "stripRoot" "extraPostFetch" "postFetch" "extension" "nativeBuildInputs" ])