diff --git a/doc/manual/command-ref/conf-file.xml b/doc/manual/command-ref/conf-file.xml
index 87f05fb1c..2ddca991f 100644
--- a/doc/manual/command-ref/conf-file.xml
+++ b/doc/manual/command-ref/conf-file.xml
@@ -321,6 +321,20 @@ false.
+ builders-use-substitutes
+
+ If set to true, Nix will instruct
+ remote build machines to use their own binary substitutes if available. In
+ practical terms, this means that remote hosts will fetch as many build
+ dependencies as possible from their own substitutes (e.g, from
+ cache.nixos.org), instead of waiting for this host to
+ upload them all. This can drastically reduce build times if the network
+ connection between this computer and the remote build host is slow. Defaults
+ to false.
+
+
+
+
fallback
If set to true, Nix will fall
diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc
index 445006b32..df579729a 100644
--- a/src/build-remote/build-remote.cc
+++ b/src/build-remote/build-remote.cc
@@ -218,9 +218,11 @@ connected:
signal(SIGALRM, old);
}
+ auto substitute = settings.buildersUseSubstitutes ? Substitute : NoSubstitute;
+
{
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying dependencies to '%s'", storeUri));
- copyPaths(store, ref(sshStore), inputs, NoRepair, NoCheckSigs);
+ copyPaths(store, ref(sshStore), inputs, NoRepair, NoCheckSigs, substitute);
}
uploadLock = -1;
@@ -240,7 +242,7 @@ connected:
if (!missing.empty()) {
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying outputs from '%s'", storeUri));
setenv("NIX_HELD_LOCKS", concatStringsSep(" ", missing).c_str(), 1); /* FIXME: ugly */
- copyPaths(ref(sshStore), store, missing, NoRepair, NoCheckSigs);
+ copyPaths(ref(sshStore), store, missing, NoRepair, NoCheckSigs, substitute);
}
return;
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index ae4b78a01..af72f7b1e 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -138,6 +138,11 @@ public:
Setting builders{this, "@" + nixConfDir + "/machines", "builders",
"A semicolon-separated list of build machines, in the format of nix.machines."};
+ Setting buildersUseSubstitutes{this, false, "builders-use-substitutes",
+ "Whether build machines should use their own substitutes for obtaining "
+ "build dependencies if possible, rather than waiting for this host to "
+ "upload them."};
+
Setting reservedSize{this, 8 * 1024 * 1024, "gc-reserved-space",
"Amount of reserved disk space for the garbage collector."};