bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18747: [PATCH] Distinguish between “offloadability” and “substitutab


From: Ludovic Courtès
Subject: bug#18747: [PATCH] Distinguish between “offloadability” and “substitutability”
Date: Wed, 01 Jul 2015 17:21:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hi again,

Nix commit 55586527 (June 2013) changed the semantics of
‘preferLocalBuild’ from “avoid offloading this derivation” to “avoid
offloading *or substituting* this derivation” (see
<http://bugs.gnu.org/18747>.)

This patch introduces a new special key, ‘substitution’, to specify
whether a derivation should be substituted.  ‘preferLocalBuild’ is kept,
but its initial semantics is restored.

As a consequence, existing uses of ‘preferLocalBuild’ must be audited to
check what exactly is intended.

WDYT?

Thanks,
Ludo’.

diff --git a/nix/libstore/misc.cc b/nix/libstore/misc.cc
index 6ecf878..bdb7a6d 100644
--- a/nix/libstore/misc.cc
+++ b/nix/libstore/misc.cc
@@ -67,6 +67,15 @@ Path findOutput(const Derivation & drv, string id)
 }
 
 
+/* Return true if we are allowed to substitute DRV.  This is the case, unless
+   DRV specifies 'substitution = "0"' in its environment.  */
+static bool substitutionAllowed(const Derivation & drv)
+{
+    auto env = drv.env;
+    auto i = env.find("substitution");
+    return i == env.end() || i->second != "0";
+}
+
 void queryMissing(StoreAPI & store, const PathSet & targets,
     PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
     unsigned long long & downloadSize, unsigned long long & narSize)
@@ -120,7 +129,7 @@ void queryMissing(StoreAPI & store, const PathSet & targets,
                 if (invalid.empty()) continue;
 
                 todoDrv.insert(*i);
-                if (settings.useSubstitutes && !willBuildLocally(drv))
+                if (settings.useSubstitutes && substitutionAllowed(drv))
                     query.insert(invalid.begin(), invalid.end());
             }
 
@@ -144,7 +153,7 @@ void queryMissing(StoreAPI & store, const PathSet & targets,
 
             PathSet outputs;
             bool mustBuild = false;
-            if (settings.useSubstitutes && !willBuildLocally(drv)) {
+            if (settings.useSubstitutes && substitutionAllowed(drv)) {
                 foreach (DerivationOutputs::iterator, j, drv.outputs) {
                     if (!wantOutput(j->first, i2.second)) continue;
                     if (!store.isValidPath(j->second.path)) {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]