diff --git a/doc/functions.xml b/doc/functions.xml
index 4193bb49f77a..e6d59ebde978 100644
--- a/doc/functions.xml
+++ b/doc/functions.xml
@@ -14,4 +14,5 @@
+
diff --git a/doc/functions/prefer-remote-fetch.xml b/doc/functions/prefer-remote-fetch.xml
new file mode 100644
index 000000000000..85f08f4eae14
--- /dev/null
+++ b/doc/functions/prefer-remote-fetch.xml
@@ -0,0 +1,27 @@
+
+ prefer-remote-fetch overlay
+
+
+ prefer-remote-fetch is an overlay that download sources
+ on remote builder. This is useful when the evaluating machine has a slow
+ upload while the builder can fetch faster directly from the source.
+ To use it, put the following snippet as a new overlay:
+
+ self: super:
+ (super.prefer-remote-fetch self super)
+
+
+ A full configuration example for that sets the overlay up for your own account,
+ could look like this
+
+
+ $ mkdir ~/.config/nixpkgs/overlays/
+ $ cat > ~/.config/nixpkgs/overlays/prefer-remote-fetch.nix <<EOF
+ self: super: super.prefer-remote-fetch self super
+ EOF
+
+
+
diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix
index 9fccc27ef632..256c86748d28 100644
--- a/pkgs/build-support/fetchgit/default.nix
+++ b/pkgs/build-support/fetchgit/default.nix
@@ -19,6 +19,7 @@ in
, # Shell code executed after the file has been fetched
# successfully. This can do things like check or transform the file.
postFetch ? ""
+, preferLocalBuild ? true
}:
/* NOTE:
@@ -66,5 +67,5 @@ stdenvNoCC.mkDerivation {
"GIT_PROXY_COMMAND" "SOCKS_SERVER"
];
- preferLocalBuild = true;
+ inherit preferLocalBuild;
}
diff --git a/pkgs/build-support/fetchhg/default.nix b/pkgs/build-support/fetchhg/default.nix
index 40ead021cdbf..41eff1f9c0c5 100644
--- a/pkgs/build-support/fetchhg/default.nix
+++ b/pkgs/build-support/fetchhg/default.nix
@@ -1,4 +1,11 @@
-{stdenvNoCC, mercurial}: {name ? null, url, rev ? null, md5 ? null, sha256 ? null, fetchSubrepos ? false}:
+{ stdenvNoCC, mercurial }:
+{ name ? null
+, url
+, rev ? null
+, md5 ? null
+, sha256 ? null
+, fetchSubrepos ? false
+, preferLocalBuild ? true }:
if md5 != null then
throw "fetchhg does not support md5 anymore, please use sha256"
@@ -18,5 +25,5 @@ stdenvNoCC.mkDerivation {
outputHash = sha256;
inherit url rev;
- preferLocalBuild = true;
+ inherit preferLocalBuild;
}
diff --git a/pkgs/build-support/fetchipfs/default.nix b/pkgs/build-support/fetchipfs/default.nix
index dc8949794221..7a66999ec569 100644
--- a/pkgs/build-support/fetchipfs/default.nix
+++ b/pkgs/build-support/fetchipfs/default.nix
@@ -14,6 +14,7 @@
, meta ? {}
, port ? "8080"
, postFetch ? ""
+, preferLocalBuild ? true
}:
assert sha512 != "" -> builtins.compareVersions "1.11" builtins.nixVersion <= 0;
@@ -42,11 +43,10 @@ if (!hasHash) then throw "Specify sha for fetchipfs fixed-output derivation" els
postFetch
ipfs
url
- port;
+ port
+ meta;
# Doing the download on a remote machine just duplicates network
# traffic, so don't do that.
- preferLocalBuild = true;
-
- inherit meta;
+ inherit preferLocalBuild;
}
diff --git a/pkgs/build-support/fetchsvn/default.nix b/pkgs/build-support/fetchsvn/default.nix
index da57d581dadd..194ce3b39b1d 100644
--- a/pkgs/build-support/fetchsvn/default.nix
+++ b/pkgs/build-support/fetchsvn/default.nix
@@ -1,6 +1,7 @@
{stdenvNoCC, subversion, glibcLocales, sshSupport ? false, openssh ? null}:
-{url, rev ? "HEAD", md5 ? "", sha256 ? "",
- ignoreExternals ? false, ignoreKeywords ? false, name ? null}:
+{url, rev ? "HEAD", md5 ? "", sha256 ? ""
+, ignoreExternals ? false, ignoreKeywords ? false, name ? null
+, preferLocalBuild ? true }:
let
repoName = with stdenvNoCC.lib;
@@ -40,5 +41,5 @@ stdenvNoCC.mkDerivation {
inherit url rev sshSupport openssh ignoreExternals ignoreKeywords;
impureEnvVars = stdenvNoCC.lib.fetchers.proxyImpureEnvVars;
- preferLocalBuild = true;
+ inherit preferLocalBuild;
}
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix
index 5f0c1384c79e..3ce90cbeab3a 100644
--- a/pkgs/build-support/fetchurl/default.nix
+++ b/pkgs/build-support/fetchurl/default.nix
@@ -87,6 +87,9 @@ in
# Passthru information, if any.
, passthru ? {}
+ # Doing the download on a remote machine just duplicates network
+ # traffic, so don't do that by default
+, preferLocalBuild ? true
}:
assert sha512 != "" -> builtins.compareVersions "1.11" builtins.nixVersion <= 0;
@@ -135,9 +138,7 @@ stdenvNoCC.mkDerivation {
nixpkgsVersion = lib.trivial.release;
- # Doing the download on a remote machine just duplicates network
- # traffic, so don't do that.
- preferLocalBuild = true;
+ inherit preferLocalBuild;
postHook = if netrcPhase == null then null else ''
${netrcPhase}
diff --git a/pkgs/build-support/prefer-remote-fetch/default.nix b/pkgs/build-support/prefer-remote-fetch/default.nix
new file mode 100644
index 000000000000..2e55e3707421
--- /dev/null
+++ b/pkgs/build-support/prefer-remote-fetch/default.nix
@@ -0,0 +1,19 @@
+# An overlay that download sources on remote builder.
+# This is useful when the evaluating machine has a slow
+# upload while the builder can fetch faster directly from the source.
+# Usage: Put the following snippet in your usual overlay definition:
+#
+# self: super:
+# (super.prefer-remote-fetch self super)
+# Full configuration example for your own account:
+#
+# $ mkdir ~/.config/nixpkgs/overlays/
+# $ echo 'self: super: super.prefer-remote-fetch self super' > ~/.config/nixpkgs/overlays/prefer-remote-fetch.nix
+#
+self: super: {
+ fetchurl = args: super.fetchurl (args // { preferLocalBuild = false; });
+ fetchgit = args: super.fetchgit (args // { preferLocalBuild = false; });
+ fetchhg = args: super.fetchhg (args // { preferLocalBuild = false; });
+ fetchsvn = args: super.fetchsvn (args // { preferLocalBuild = false; });
+ fetchipfs = args: super.fetchipfs (args // { preferLocalBuild = false; });
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 524741a0da04..a61bd8401679 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -207,6 +207,8 @@ in
fetchMavenArtifact = callPackage ../build-support/fetchmavenartifact { };
+ prefer-remote-fetch = import ../build-support/prefer-remote-fetch;
+
global-platform-pro = callPackage ../development/tools/global-platform-pro/default.nix { };
graph-easy = callPackage ../tools/graphics/graph-easy { };