about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2008-08-22 15:53:21 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2008-08-22 15:53:21 +0000
commiteebb241519615e0e82704ab80aacdd4f510f2555 (patch)
tree4e6773de706732c0379d6a260b2d6d0bdb5cff05
parent4457e49a90647bcf91f50e3d0758e1b623b10c27 (diff)
downloadnixlib-eebb241519615e0e82704ab80aacdd4f510f2555.tar
nixlib-eebb241519615e0e82704ab80aacdd4f510f2555.tar.gz
nixlib-eebb241519615e0e82704ab80aacdd4f510f2555.tar.bz2
nixlib-eebb241519615e0e82704ab80aacdd4f510f2555.tar.lz
nixlib-eebb241519615e0e82704ab80aacdd4f510f2555.tar.xz
nixlib-eebb241519615e0e82704ab80aacdd4f510f2555.tar.zst
nixlib-eebb241519615e0e82704ab80aacdd4f510f2555.zip
* Write the list of mirrors to a file that we can reuse between
  fetchurl instantiations, instead of passing the mirrors to fetchurl
  instantiations via environment variables.  This makes the resulting
  store derivations (.drv files) much smaller, which in turn makes
  nix-env/nix-instantiate faster (4.8 -> 4.2 seconds on nix-env -qa
  --out-path).

svn path=/nixpkgs/trunk/; revision=12695
-rw-r--r--pkgs/build-support/fetchurl/builder.sh2
-rw-r--r--pkgs/build-support/fetchurl/default.nix44
-rw-r--r--pkgs/build-support/fetchurl/write-mirror-list.sh4
3 files changed, 34 insertions, 16 deletions
diff --git a/pkgs/build-support/fetchurl/builder.sh b/pkgs/build-support/fetchurl/builder.sh
index bfa57143b4b7..2276bfc1de3d 100644
--- a/pkgs/build-support/fetchurl/builder.sh
+++ b/pkgs/build-support/fetchurl/builder.sh
@@ -1,5 +1,7 @@
 source $stdenv/setup
 
+source $mirrorsFile
+
 if test -n "$showURLs"; then
     header "downloading file $name with $outputHashAlgo hash $outputHash..."
 fi
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix
index 2643008e33fb..ee3800f6d9bb 100644
--- a/pkgs/build-support/fetchurl/default.nix
+++ b/pkgs/build-support/fetchurl/default.nix
@@ -3,6 +3,30 @@
 
 {stdenv, curl}: # Note that `curl' may be `null', in case of the native stdenv.
 
+let
+
+  mirrors = import ./mirrors.nix;
+
+  # Write the list of mirrors to a file that we can reuse between
+  # fetchurl instantiations, instead of passing the mirrors to
+  # fetchurl instantiations via environment variables.  This makes the
+  # resulting store derivations (.drv files) much smaller, which in
+  # turn makes nix-env/nix-instantiate faster.
+  mirrorsFile =
+    stdenv.mkDerivation ({
+      name = "mirrors-list";
+      builder = ./write-mirror-list.sh;
+    } // mirrors);
+
+  # Names of the master sites that are mirrored (i.e., "sourceforge",
+  # "gnu", etc.).
+  sites =
+    if builtins ? attrNames
+    then builtins.attrNames mirrors
+    else [] /* backwards compatibility */;
+
+in
+      
 { # URL to fetch.
   url ? ""
 
@@ -36,23 +60,16 @@ let
 
   urls_ = if urls != [] then urls else [url];
 
-  mirrors = import ./mirrors.nix;
-
-  # Names of the master sites that are mirrored (i.e., "sourceforge",
-  # "gnu", etc.).
-  sites =
-    if builtins ? attrNames
-    then builtins.attrNames mirrors
-    else [] /* backwards compatibility */;
-  
 in
 
-stdenv.mkDerivation ({
+stdenv.mkDerivation {
   name =
     if showURLs then "urls"
     else if name != "" then name
     else baseNameOf (toString (builtins.head urls_));
+    
   builder = ./builder.sh;
+  
   buildInputs = [curl];
 
   urls = urls_;
@@ -82,10 +99,5 @@ stdenv.mkDerivation ({
     "NIX_HASHED_MIRRORS"
   ] ++ (map (site: "NIX_MIRRORS_${site}") sites);
 
-  inherit showURLs;
+  inherit showURLs mirrorsFile;
 }
-
-# Pass the mirror locations to the builder.
-// mirrors
-
-)
diff --git a/pkgs/build-support/fetchurl/write-mirror-list.sh b/pkgs/build-support/fetchurl/write-mirror-list.sh
new file mode 100644
index 000000000000..55508742dd36
--- /dev/null
+++ b/pkgs/build-support/fetchurl/write-mirror-list.sh
@@ -0,0 +1,4 @@
+source $stdenv/setup
+
+# !!! this is kinda hacky.
+set | grep '^[a-zA-Z]\+=.*://' > $out