aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual/command-ref/conf-file.xml14
-rw-r--r--scripts/install-darwin-multi-user.sh2
-rw-r--r--src/build-remote/build-remote.cc6
-rw-r--r--src/libexpr/primops/fetchGit.cc1
-rw-r--r--src/libstore/globals.hh5
-rw-r--r--src/nix-daemon/nix-daemon.cc2
-rw-r--r--tests/fetchGit.sh13
7 files changed, 38 insertions, 5 deletions
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</literal>.</para>
</varlistentry>
+ <varlistentry><term><literal>builders-use-substitutes</literal></term>
+
+ <listitem><para>If set to <literal>true</literal>, 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
+ <literal>cache.nixos.org</literal>), 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 <literal>false</literal>.</para></listitem>
+
+ </varlistentry>
+
+
<varlistentry><term><literal>fallback</literal></term>
<listitem><para>If set to <literal>true</literal>, Nix will fall
diff --git a/scripts/install-darwin-multi-user.sh b/scripts/install-darwin-multi-user.sh
index 7bd00e42b..91194a299 100644
--- a/scripts/install-darwin-multi-user.sh
+++ b/scripts/install-darwin-multi-user.sh
@@ -33,7 +33,7 @@ readonly NIX_FIRST_BUILD_UID="30001"
readonly NIX_ROOT="/nix"
readonly PLIST_DEST=/Library/LaunchDaemons/org.nixos.nix-daemon.plist
-readonly PROFILE_TARGETS=("/etc/profile" "/etc/bashrc" "/etc/zshrc")
+readonly PROFILE_TARGETS=("/etc/bashrc" "/etc/zshrc")
readonly PROFILE_BACKUP_SUFFIX=".backup-before-nix"
readonly PROFILE_NIX_FILE="$NIX_ROOT/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
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<Store>(sshStore), inputs, NoRepair, NoCheckSigs);
+ copyPaths(store, ref<Store>(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<Store>(sshStore), store, missing, NoRepair, NoCheckSigs);
+ copyPaths(ref<Store>(sshStore), store, missing, NoRepair, NoCheckSigs, substitute);
}
return;
diff --git a/src/libexpr/primops/fetchGit.cc b/src/libexpr/primops/fetchGit.cc
index 0d0b11958..fb664cffb 100644
--- a/src/libexpr/primops/fetchGit.cc
+++ b/src/libexpr/primops/fetchGit.cc
@@ -85,7 +85,6 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
Path cacheDir = getCacheDir() + "/nix/git";
if (!pathExists(cacheDir)) {
- createDirs(cacheDir);
runProgram("git", true, { "init", "--bare", cacheDir });
}
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<std::string> builders{this, "@" + nixConfDir + "/machines", "builders",
"A semicolon-separated list of build machines, in the format of nix.machines."};
+ Setting<bool> 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<off_t> reservedSize{this, 8 * 1024 * 1024, "gc-reserved-space",
"Amount of reserved disk space for the garbage collector."};
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 5629cc64b..b5d49b642 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -411,7 +411,7 @@ static void performOp(TunnelLogger * logger, ref<LocalStore> store,
/* Repairing is not atomic, so disallowed for "untrusted"
clients. */
if (mode == bmRepair && !trusted)
- throw Error("repairing is not supported when building through the Nix daemon");
+ throw Error("repairing is not allowed because you are not in 'trusted-users'");
}
logger->startWork();
store->buildPaths(drvs, mode);
diff --git a/tests/fetchGit.sh b/tests/fetchGit.sh
index 65d673c08..b556fe594 100644
--- a/tests/fetchGit.sh
+++ b/tests/fetchGit.sh
@@ -119,3 +119,16 @@ path4=$(nix eval --raw "(builtins.fetchGit $repo).outPath")
# Confirm same as 'dev' branch
path5=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath")
[[ $path3 = $path5 ]]
+
+
+# Nuke the cache
+rm -rf $TEST_HOME/.cache/nix/git
+
+# Try again, but without 'git' on PATH
+NIX=$(command -v nix)
+# This should fail
+(! PATH= $NIX eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath" )
+
+# Try again, with 'git' available. This should work.
+path5=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath")
+[[ $path3 = $path5 ]]