From 6c4fd2e3df5124dd625711135d82e39f2220d7e3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 11 Sep 2007 13:48:53 +0000 Subject: [PATCH] * Allow the user to override the list of content-addressable mirrors from the command-line by setting the NIX_HASHED_MIRRORS environment variable. svn path=/nixpkgs/trunk/; revision=9301 --- pkgs/build-support/fetchurl/builder.sh | 4 ++++ pkgs/build-support/fetchurl/default.nix | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/fetchurl/builder.sh b/pkgs/build-support/fetchurl/builder.sh index f91edf7c281..511839655be 100644 --- a/pkgs/build-support/fetchurl/builder.sh +++ b/pkgs/build-support/fetchurl/builder.sh @@ -46,6 +46,10 @@ finish() { tryHashedMirrors() { + if test -n "$NIX_HASHED_MIRRORS"; then + hashedMirrors="$NIX_HASHED_MIRRORS" + fi + for mirror in $hashedMirrors; do url="$mirror/$outputHashAlgo/$outputHash" if $curl --fail --silent --show-error --head "$url" \ diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix index eb40c4c6a91..e752b9313e9 100644 --- a/pkgs/build-support/fetchurl/default.nix +++ b/pkgs/build-support/fetchurl/default.nix @@ -52,11 +52,17 @@ stdenv.mkDerivation ({ outputHash = if outputHash != "" then outputHash else if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5; - # We borrow these environment variables from the caller to allow - # easy proxy configuration. This is impure, but a fixed-output - # derivation like fetchurl is allowed to do so since its result is - # by definition pure. - impureEnvVars = ["http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"]; + impureEnvVars = [ + # We borrow these environment variables from the caller to allow + # easy proxy configuration. This is impure, but a fixed-output + # derivation like fetchurl is allowed to do so since its result is + # by definition pure. + "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy" + + # This variable allows the user to override hashedMirrors from the + # command-line. + "NIX_HASHED_MIRRORS" + ]; } # Pass the mirror locations to the builder.