about summary refs log tree commit diff
path: root/pkgs/build-support/fetchzip
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-05-09 15:50:40 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-05-09 15:53:44 +0200
commitea36f3b86892263d172fa3d0d0d4ae00d82a0edc (patch)
tree91862989d1274c3257ea267814eb2bb071a01580 /pkgs/build-support/fetchzip
parent0d50061b4f9a23d5d2d61404a4d38122603f2b63 (diff)
fetchFromGitHub: Use .tar.gz instead of .zip
Also clean up the name attribute of fetchzip derivations a bit.
Diffstat (limited to 'pkgs/build-support/fetchzip')
-rw-r--r--pkgs/build-support/fetchzip/default.nix24
1 files changed, 13 insertions, 11 deletions
diff --git a/pkgs/build-support/fetchzip/default.nix b/pkgs/build-support/fetchzip/default.nix
index 6b77b6474efc4..7c6e16a058926 100644
--- a/pkgs/build-support/fetchzip/default.nix
+++ b/pkgs/build-support/fetchzip/default.nix
@@ -1,19 +1,21 @@
-# This function downloads and unpacks a zip file. This is primarily
-# useful for dynamically generated zip files, such as GitHub's
-# /archive URLs, where the unpacked content of the zip file doesn't
-# change, but the zip file itself may (e.g. due to minor changes in
-# the compression algorithm, or changes in timestamps).
+# This function downloads and unpacks an archive file, such as a zip
+# or tar file. This is primarily useful for dynamically generated
+# archives, such as GitHub's /archive URLs, where the unpacked content
+# of the zip file doesn't change, but the zip file itself may
+# (e.g. due to minor changes in the compression algorithm, or changes
+# in timestamps).
 
 { lib, fetchurl, unzip }:
 
 { # Optionally move the contents of the unpacked tree up one level.
   stripRoot ? true
+, url
 , ... } @ args:
 
-fetchurl (args // {
-  # Apply a suffix to the name. Otherwise, unpackPhase will get
-  # confused by the .zip extension.
-  nameSuffix = "-unpacked";
+fetchurl ({
+  # Remove the extension, because otherwise unpackPhase will get
+  # confused. FIXME: fix unpackPhase.
+  name = args.name or lib.removeSuffix ".zip" (lib.removeSuffix ".tar.gz" (baseNameOf url));
 
   recursiveHash = true;
 
@@ -24,7 +26,7 @@ fetchurl (args // {
       export PATH=${unzip}/bin:$PATH
       mkdir $out
       cd $out
-      renamed="$TMPDIR/''${name%-unpacked}"
+      renamed="$TMPDIR/${baseNameOf url}"
       mv "$downloadedFile" "$renamed"
       unpackFile "$renamed"
     ''
@@ -39,4 +41,4 @@ fetchurl (args // {
       mv $out/$fn/* "$out/"
       rmdir "$out/$fn"
     '';
-})
+} // args)