summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/applications/video/zapping/default.nix3
-rw-r--r--pkgs/build-support/fetchurl/builder.sh56
-rw-r--r--pkgs/build-support/fetchurl/default.nix14
-rw-r--r--pkgs/build-support/fetchurl/mirrors.nix35
-rw-r--r--pkgs/development/compilers/gcc-4.1/default.nix6
-rw-r--r--pkgs/development/compilers/gcc-4.2/default.nix18
-rw-r--r--pkgs/games/gemrb/default.nix6
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.20.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.21.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.22.nix2
10 files changed, 109 insertions, 35 deletions
diff --git a/pkgs/applications/video/zapping/default.nix b/pkgs/applications/video/zapping/default.nix
index 444cd974f8f..29fcc31e8b9 100644
--- a/pkgs/applications/video/zapping/default.nix
+++ b/pkgs/applications/video/zapping/default.nix
@@ -20,8 +20,9 @@ stdenv.mkDerivation {
   name = "zapping-0.9.6";
 
   builder = ./builder.sh;
+
   src = fetchurl {
-    url = http://heanet.dl.sourceforge.net/sourceforge/zapping/zapping-0.9.6.tar.bz2;
+    url = mirror://sourceforge/zapping/zapping-0.9.6.tar.bz2;
     md5 = "8306775c6a11de4d72345b5eee970ea6";
   };
 
diff --git a/pkgs/build-support/fetchurl/builder.sh b/pkgs/build-support/fetchurl/builder.sh
index c6ccf708855..f91edf7c281 100644
--- a/pkgs/build-support/fetchurl/builder.sh
+++ b/pkgs/build-support/fetchurl/builder.sh
@@ -45,22 +45,52 @@ finish() {
 }
 
 
-for mirror in $hashedMirrors; do
-    url="$mirror/$outputHashAlgo/$outputHash"
-    if $curl --fail --silent --show-error --head "$url" \
-        --write-out "%{http_code}" --output /dev/null > code 2> log; then
-        tryDownload "$url"
-        if test -n "$success"; then finish; fi
+tryHashedMirrors() {
+    for mirror in $hashedMirrors; do
+        url="$mirror/$outputHashAlgo/$outputHash"
+        if $curl --fail --silent --show-error --head "$url" \
+            --write-out "%{http_code}" --output /dev/null > code 2> log; then
+            tryDownload "$url"
+            if test -n "$success"; then finish; fi
+        else
+            # Be quiet about 404 errors, which we interpret as the file
+            # not being present on this particular mirror.
+            if test "$(cat code)" != 404; then
+                echo "error checking the existence of $url:"
+                cat log
+            fi
+        fi
+    done
+}
+
+
+urls2=
+for url in $urls; do
+    if test "${url:0:9}" != "mirror://"; then
+        urls2="$urls2 $url"
     else
-        # Be quiet about 404 errors, which we interpret as the file
-        # not being present on this particular mirror.
-        if test "$(cat code)" != 404; then
-            echo "error checking the existence of $url:"
-            cat log
+        url2="${url:9}"; echo "${url2/\// }" > split; read site fileName < split
+        #varName="mirror_$site"
+        varName="$site" # !!! danger of name clash, fix this
+        if test -z "${!varName}"; then
+            echo "warning: unknown mirror:// site \`$site'"
+        else
+            # Assume that SourceForge/GNU/kernel mirrors have better
+            # bandwidth than nix.cs.uu.nl.
+            preferHashedMirrors=
+            
+            for url3 in ${!varName}; do
+                urls2="$urls2 $url3$fileName";
+            done
         fi
     fi
 done
+urls="$urls2"
+
 
+if test -n "$preferHashedMirrors"; then
+    tryHashedMirrors
+fi
 
 success=
 for url in $urls; do
@@ -68,6 +98,10 @@ for url in $urls; do
     if test -n "$success"; then finish; fi
 done
 
+if test -z "$preferHashedMirrors"; then
+    tryHashedMirrors
+fi
+
 
 echo "error: cannot download $name from any mirror"
 exit 1
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix
index c79f3d214c6..eb40c4c6a91 100644
--- a/pkgs/build-support/fetchurl/default.nix
+++ b/pkgs/build-support/fetchurl/default.nix
@@ -30,7 +30,7 @@ assert (outputHash != "" && outputHashAlgo != "")
 
 let urls_ = if urls != [] then urls else [url]; in
 
-stdenv.mkDerivation {
+stdenv.mkDerivation ({
   name =
     if name != "" then name
     else baseNameOf (toString (builtins.head urls_));
@@ -39,10 +39,9 @@ stdenv.mkDerivation {
 
   urls = urls_;
 
-  # The content-addressable mirrors.
-  hashedMirrors = [
-    http://nix.cs.uu.nl/dist/tarballs
-  ];
+  # If set, prefer the content-addressable mirrors
+  # (http://nix.cs.uu.nl/dist/tarballs) over the original URLs.
+  preferHashedMirrors = true;
 
   # Compatibility with Nix <= 0.7.
   id = md5;
@@ -59,3 +58,8 @@ stdenv.mkDerivation {
   # by definition pure.
   impureEnvVars = ["http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"];
 }
+
+# Pass the mirror locations to the builder.
+// (import ./mirrors.nix)
+
+)
diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix
new file mode 100644
index 00000000000..3ffbf706eb2
--- /dev/null
+++ b/pkgs/build-support/fetchurl/mirrors.nix
@@ -0,0 +1,35 @@
+{
+  # Content-addressable Nix mirrors.
+  hashedMirrors = [
+    http://nix.cs.uu.nl/dist/tarballs
+  ];
+
+  # Mirrors for mirror://site/filename URIs, where "site" is
+  # "sourceforge", "gnu", etc.
+  
+  # SourceForge.
+  sourceforge = [
+    http://prdownloads.sourceforge.net/
+    http://heanet.dl.sourceforge.net/sourceforge/
+    http://surfnet.dl.sourceforge.net/sourceforge/
+    http://dfn.dl.sourceforge.net/sourceforge/
+    http://mesh.dl.sourceforge.net/sourceforge/
+    http://ovh.dl.sourceforge.net/sourceforge/
+    http://osdn.dl.sourceforge.net/sourceforge/
+    http://kent.dl.sourceforge.net/sourceforge/
+  ];
+
+  # GNU.
+  gnu = [
+    ftp://ftp.nluug.nl/pub/gnu/
+    http://mirrors.kernel.org/gnu/
+    http://ftp.gnu.org/pub/gnu/
+  ];
+
+  # kernel.org's /pub (/pub/{linux,software}) tree.
+  kernel = [
+    http://www.all.kernel.org/pub/
+    http://www.eu.kernel.org/pub/
+    http://www.de.kernel.org/pub/
+  ];
+}
diff --git a/pkgs/development/compilers/gcc-4.1/default.nix b/pkgs/development/compilers/gcc-4.1/default.nix
index 4473d8a229f..39b3e4a28eb 100644
--- a/pkgs/development/compilers/gcc-4.1/default.nix
+++ b/pkgs/development/compilers/gcc-4.1/default.nix
@@ -14,15 +14,15 @@ stdenv.mkDerivation {
   
   src =
     [(fetchurl {
-      url = ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.1.2/gcc-core-4.1.2.tar.bz2;
+      url = mirror://gnu/gcc/gcc-4.1.2/gcc-core-4.1.2.tar.bz2;
       sha256 = "07binc1hqlr0g387zrg5sp57i12yzd5ja2lgjb83bbh0h3gwbsbv";
     })] ++
     (if /*langCC*/ true then [(fetchurl {
-      url = ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.1.2/gcc-g++-4.1.2.tar.bz2;
+      url = mirror://gnu/gcc/gcc-4.1.2/gcc-g++-4.1.2.tar.bz2;
       sha256 = "1qm2izcxna10jai0v4s41myki0xkw9174qpl6k1rnrqhbx0sl1hc";
     })] else []) ++
     (if langF77 then [(fetchurl {
-      url = ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.1.2/gcc-fortran-4.1.2.tar.bz2;
+      url = mirror://gnu/gcc/gcc-4.1.2/gcc-fortran-4.1.2.tar.bz2;
       sha256 = "0772dhmm4gc10420h0d0mfkk2sirvjmjxz8j0ywm8wp5qf8vdi9z";
     })] else []);
     
diff --git a/pkgs/development/compilers/gcc-4.2/default.nix b/pkgs/development/compilers/gcc-4.2/default.nix
index 2a7cf8fa89d..2681531f204 100644
--- a/pkgs/development/compilers/gcc-4.2/default.nix
+++ b/pkgs/development/compilers/gcc-4.2/default.nix
@@ -13,18 +13,18 @@ stdenv.mkDerivation {
   builder = ./builder.sh;
   
   src =
-    [(fetchurl {
-      url = http://ftp.gnu.org/pub/gnu/gcc/gcc-4.2.0/gcc-core-4.2.0.tar.bz2;
+    optional /*langC*/ true (fetchurl {
+      url = mirror://gnu/gcc/gcc-4.2.0/gcc-core-4.2.0.tar.bz2;
       sha256 = "0ykhzxhr8857dr97z0j9wyybfz1kjr71xk457cfapfw5fjas4ny1";
-    })] ++
-    (if /*langCC*/ true then [(fetchurl {
-      url = http://ftp.gnu.org/pub/gnu/gcc/gcc-4.2.0/gcc-g++-4.2.0.tar.bz2;
+    }) ++
+    optional /*langCC*/ true (fetchurl {
+      url = mirror://gnu/gcc/gcc-4.2.0/gcc-g++-4.2.0.tar.bz2;
       sha256 = "0k5ribrfdp9vmljxrglcgx2j2r7xnycd1rvd8sny2y5cj0l8ps12";
-    })] else []) ++
-    (if langF77 then [(fetchurl {
-      url = http://ftp.gnu.org/pub/gnu/gcc/gcc-4.2.0/gcc-fortran-4.2.0.tar.bz2;
+    }) ++
+    optional langF77 (fetchurl {
+      url = mirror://gnu/gcc/gcc-4.2.0/gcc-fortran-4.2.0.tar.bz2;
       sha256 = "0vw07qv6qpa5cgxc0qxraq6li2ibh8zrp65jrg92v4j63ivvi3hh";
-    })] else []);
+    });
     
   patches =
     [./pass-cxxcpp.patch]
diff --git a/pkgs/games/gemrb/default.nix b/pkgs/games/gemrb/default.nix
index 8dbc3861df0..46ab9abe746 100644
--- a/pkgs/games/gemrb/default.nix
+++ b/pkgs/games/gemrb/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, SDL, openal, freealut, zlib, libpng, python}:
 
 stdenv.mkDerivation {
-  name = "gemrb-0.2.8";
+  name = "gemrb-0.2.9";
   
   src = fetchurl {
-    url = http://heanet.dl.sourceforge.net/sourceforge/gemrb/gemrb-0.2.8.tar.gz;
-    sha256 = "1a0pald30m941i67nc7silz36pc1ixrfgkvsr7dcac6mwqmi89kr";
+    url = mirror://sourceforge/gemrb/gemrb-0.2.9.tar.gz;
+    sha256 = "0mygig4icx87a5skdv33yiwn8q4mv55f5qsks4sn40hrs69gcih0";
   };
 
   buildInputs = [SDL openal freealut libpng python];
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.20.nix b/pkgs/os-specific/linux/kernel/linux-2.6.20.nix
index 869d2e7b31a..3299ba5a3cb 100644
--- a/pkgs/os-specific/linux/kernel/linux-2.6.20.nix
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.20.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation {
   builder = ./builder.sh;
   
   src = fetchurl {
-    url = "http://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-${version}.tar.bz2";
+    url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
     sha256 = "1s7vdpg2897q5pcyxxypqcnibwpbdawbimkf3pngmahj8wr9c03x";
   };
   
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.21.nix b/pkgs/os-specific/linux/kernel/linux-2.6.21.nix
index b4fd5ad297d..e7fc2943a5c 100644
--- a/pkgs/os-specific/linux/kernel/linux-2.6.21.nix
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.21.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation {
   builder = ./builder.sh;
   
   src = fetchurl {
-    url = "http://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-${version}.tar.bz2";
+    url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
     sha256 = "1c8ndsz35qd8vyng3xsxjjkjv5bnzyvc9b5vd85fz5v0bjp8hx50";
   };
   
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.22.nix b/pkgs/os-specific/linux/kernel/linux-2.6.22.nix
index 2229b396e77..f0048b44234 100644
--- a/pkgs/os-specific/linux/kernel/linux-2.6.22.nix
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.22.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation {
   builder = ./builder.sh;
   
   src = fetchurl {
-    url = "http://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-${version}.tar.bz2";
+    url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
     sha256 = "1n8azbky36l27y6h44pp9abc7h3k3vp6f4y1pvrqgzmywxp6gakb";
   };