GNU bug report logs -
#18747
"preferLocalBuild" fails to distinguish between offload and substitute
Previous Next
Reported by: ludo <at> gnu.org (Ludovic Courtès)
Date: Thu, 16 Oct 2014 15:27:01 UTC
Severity: normal
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
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’.
[Message part 2 (text/x-patch, inline)]
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)) {
This bug report was last modified 9 years and 329 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.