From db5b86ef13026d7f034527005ab231ddc2b7d2c1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 Apr 2012 19:15:34 -0400 Subject: [PATCH] =?UTF-8?q?*=20Add=20an=20option=20=E2=80=98build-use-subs?= =?UTF-8?q?titutes=E2=80=99,=20which=20can=20be=20set=20to=20=E2=80=98fals?= =?UTF-8?q?e=E2=80=99=20=20=20to=20disable=20use=20of=20substitutes;=20i.e?= =?UTF-8?q?.,=20force=20building=20from=20source.=20=20=20Fixes=20Nix/221.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/manual/conf-file.xml | 9 +++++++++ src/libstore/build.cc | 2 +- src/libstore/misc.cc | 4 +++- src/libstore/remote-store.cc | 3 +++ src/libstore/worker-protocol.hh | 2 +- src/nix-worker/nix-worker.cc | 7 ++++++- 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/doc/manual/conf-file.xml b/doc/manual/conf-file.xml index 10e6d08cd..f220c8374 100644 --- a/doc/manual/conf-file.xml +++ b/doc/manual/conf-file.xml @@ -225,6 +225,15 @@ env-keep-derivations = false + build-use-substitutes + + If set to true (default), Nix + will use binary substitutes if available. This option can be + disabled to force building from source. + + + + build-chroot-dirs When builds are performed in a chroot environment, diff --git a/src/libstore/build.cc b/src/libstore/build.cc index acc292305..789a7f617 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -962,7 +962,7 @@ void DerivationGoal::haveDerivation() foreach (PathSet::iterator, i, invalidOutputs) /* Don't bother creating a substitution goal if there are no substitutes. */ - if (worker.store.hasSubstitutes(*i)) + if (queryBoolSetting("build-use-substitutes", true) && worker.store.hasSubstitutes(*i)) addWaitee(worker.makeSubstitutionGoal(*i)); if (waitees.empty()) /* to prevent hang (no wake-up event) */ diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index 4ac0afe84..093499936 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -1,6 +1,7 @@ #include "misc.hh" #include "store-api.hh" #include "local-store.hh" +#include "globals.hh" namespace nix { @@ -69,7 +70,8 @@ void queryMissing(StoreAPI & store, const PathSet & targets, bool mustBuild = false; foreach (DerivationOutputs::iterator, i, drv.outputs) - if (!store.isValidPath(i->second.path) && !store.hasSubstitutes(i->second.path)) + if (!store.isValidPath(i->second.path) && + !(queryBoolSetting("build-use-substitutes", true) && store.hasSubstitutes(i->second.path))) mustBuild = true; if (mustBuild) { diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 0b8fa36f6..0fd759b07 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -197,6 +197,9 @@ void RemoteStore::setOptions() } if (GET_PROTOCOL_MINOR(daemonVersion) >= 6) writeInt(buildCores, to); + if (GET_PROTOCOL_MINOR(daemonVersion) >= 10) + writeInt(queryBoolSetting("build-use-substitutes", true), to); + processStderr(); } diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index ef1e0993d..6e0aadad4 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -8,7 +8,7 @@ namespace nix { #define WORKER_MAGIC_1 0x6e697863 #define WORKER_MAGIC_2 0x6478696f -#define PROTOCOL_VERSION 0x109 +#define PROTOCOL_VERSION 0x10a #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00) #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff) diff --git a/src/nix-worker/nix-worker.cc b/src/nix-worker/nix-worker.cc index 4b0c9e319..c69b9de50 100644 --- a/src/nix-worker/nix-worker.cc +++ b/src/nix-worker/nix-worker.cc @@ -513,8 +513,13 @@ static void performOp(unsigned int clientVersion, logType = (LogType) readInt(from); printBuildTrace = readInt(from) != 0; } - if (GET_PROTOCOL_MINOR(clientVersion) >= 6) { + if (GET_PROTOCOL_MINOR(clientVersion) >= 6) buildCores = readInt(from); + if (GET_PROTOCOL_MINOR(clientVersion) >= 10) { + int x = readInt(from); + Strings ss; + ss.push_back(x == 0 ? "false" : "true"); + overrideSetting("build-use-substitutes", ss); } startWork(); stopWork();