lib/fetchers.nix: factor out impure proxy vars (#18702)

Apparently everyone just copied those variables, instead of creating a
library constant for them. Some even removed the comment. -.-
This commit is contained in:
Profpatsch 2016-09-17 21:50:01 +02:00 committed by GitHub
parent aa7ab01131
commit 61462c94e6
14 changed files with 29 additions and 72 deletions

View file

@ -31,6 +31,7 @@ let
# domain-specific # domain-specific
sandbox = import ./sandbox.nix; sandbox = import ./sandbox.nix;
fetchers = import ./fetchers.nix;
in in
{ inherit trivial { inherit trivial
@ -39,7 +40,7 @@ in
modules options types modules options types
licenses platforms systems licenses platforms systems
debug misc debug misc
sandbox; sandbox fetchers;
} }
# !!! don't include everything at top-level; perhaps only the most # !!! don't include everything at top-level; perhaps only the most
# commonly used functions. # commonly used functions.

12
lib/fetchers.nix Normal file
View file

@ -0,0 +1,12 @@
# snippets that can be shared by mutliple fetchers (pkgs/build-support)
{
proxyImpureEnvVars = [
# 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"
];
}

View file

@ -157,9 +157,7 @@ in rec {
fi fi
''; '';
impureEnvVars = [ impureEnvVars = lib.fetchers.proxyImpureEnvVars;
"http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"
];
}; };
in { in {

View file

@ -10,9 +10,5 @@ stdenv.mkDerivation {
buildInputs = [ curl ]; buildInputs = [ curl ];
# We borrow these environment variables from the caller to allow impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
# 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"];
} }

View file

@ -10,9 +10,5 @@ stdenv.mkDerivation {
buildInputs = [ curl ]; buildInputs = [ curl ];
# We borrow these environment variables from the caller to allow impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
# 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"];
} }

View file

@ -26,17 +26,11 @@ let layer = stdenv.mkDerivation {
outputHash = sha256; outputHash = sha256;
outputHashMode = "recursive"; outputHashMode = "recursive";
impureEnvVars = [ impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
# 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 pass additional options to curl # This variable allows the user to pass additional options to curl
"NIX_CURL_FLAGS" "NIX_CURL_FLAGS"
]; ];
# Doing the download on a remote machine just duplicates network # Doing the download on a remote machine just duplicates network
# traffic, so don't do that. # traffic, so don't do that.
preferLocalBuild = true; preferLocalBuild = true;

View file

@ -1,15 +1,5 @@
{ stdenv, curl, adc_user, adc_pass }: { stdenv, curl, adc_user, adc_pass }:
let
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"
];
in
{ # Path to fetch. { # Path to fetch.
path path

View file

@ -17,12 +17,6 @@ stdenv.mkDerivation {
eggName = name; eggName = name;
impureEnvVars = [ impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
# 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"
];
} }

View file

@ -56,13 +56,9 @@ stdenv.mkDerivation {
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
impureEnvVars = [ impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars ++ [
# We borrow these environment variables from the caller to allow "GIT_PROXY_COMMAND" "SOCKS_SERVER"
# 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" "GIT_PROXY_COMMAND" "SOCKS_SERVER"
];
preferLocalBuild = true; preferLocalBuild = true;
} }

View file

@ -6,9 +6,7 @@ stdenv.mkDerivation {
builder = ./builder.sh; builder = ./builder.sh;
buildInputs = [mercurial]; buildInputs = [mercurial];
impureEnvVars = [ impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
"http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"
];
# Nix <= 0.7 compatibility. # Nix <= 0.7 compatibility.
id = md5; id = md5;

View file

@ -19,12 +19,7 @@ stdenv.mkDerivation {
dbs = defaultDBMirrors ++ dbs; dbs = defaultDBMirrors ++ dbs;
inherit branch cacheDB name selector; inherit branch cacheDB name selector;
impureEnvVars = [ impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
# 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"
];
} }

View file

@ -33,13 +33,6 @@ stdenv.mkDerivation {
inherit url rev sshSupport openssh ignoreExternals; inherit url rev sshSupport openssh ignoreExternals;
impureEnvVars = [ impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
# 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"
];
preferLocalBuild = true; preferLocalBuild = true;
} }

View file

@ -20,13 +20,7 @@ let
# "gnu", etc.). # "gnu", etc.).
sites = builtins.attrNames mirrors; sites = builtins.attrNames mirrors;
impureEnvVars = [ impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars ++ [
# 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 pass additional options to curl # This variable allows the user to pass additional options to curl
"NIX_CURL_FLAGS" "NIX_CURL_FLAGS"

View file

@ -20,6 +20,6 @@ stdenv.mkDerivation {
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHash = sha256; outputHash = sha256;
impureEnvVars = [ "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy" ]; impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
preferLocalBuild = true; preferLocalBuild = true;
} }