about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-06-20T17·26+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-06-20T17·26+0200
commit5558652709f27e8a887580b77b93c705659d7a4b (patch)
tree3579a66827b1a41af77c8b38aaa591295824da9b /src/libstore/build.cc
parent1906cce6fcea88d07b55c0b9734da39675e17a4d (diff)
Don't substitute derivations that have preferLocalBuild set
In particular this means that "trivial" derivations such as writeText
are not substituted, reducing the number of GET requests to the binary
cache by about 200 on a typical NixOS configuration.
Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 20ed2de39005..6e0a2b97bff0 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1072,7 +1072,7 @@ void DerivationGoal::haveDerivation()
     /* We are first going to try to create the invalid output paths
        through substitutes.  If that doesn't work, we'll build
        them. */
-    if (settings.useSubstitutes)
+    if (settings.useSubstitutes && !willBuildLocally(drv))
         foreach (PathSet::iterator, i, invalidOutputs)
             addWaitee(worker.makeSubstitutionGoal(*i, repair));
 
@@ -1273,6 +1273,12 @@ static bool canBuildLocally(const string & platform)
 }
 
 
+bool willBuildLocally(Derivation & drv)
+{
+    return drv.env["preferLocalBuild"] == "1" && canBuildLocally(drv.platform);
+}
+
+
 void DerivationGoal::tryToBuild()
 {
     trace("trying to build");
@@ -1337,11 +1343,10 @@ void DerivationGoal::tryToBuild()
 
     /* Don't do a remote build if the derivation has the attribute
        `preferLocalBuild' set. */
-    bool preferLocalBuild =
-        drv.env["preferLocalBuild"] == "1" && canBuildLocally(drv.platform);
+    bool buildLocally = willBuildLocally(drv);
 
     /* Is the build hook willing to accept this job? */
-    if (!preferLocalBuild) {
+    if (!buildLocally) {
         switch (tryBuildHook()) {
             case rpAccept:
                 /* Yes, it has started doing so.  Wait until we get
@@ -1364,7 +1369,7 @@ void DerivationGoal::tryToBuild()
        derivation prefers to be done locally, do it even if
        maxBuildJobs is 0. */
     unsigned int curBuilds = worker.getNrLocalBuilds();
-    if (curBuilds >= settings.maxBuildJobs && !(preferLocalBuild && curBuilds == 0)) {
+    if (curBuilds >= settings.maxBuildJobs && !(buildLocally && curBuilds == 0)) {
         worker.waitForBuildSlot(shared_from_this());
         outputLocks.unlock();
         return;