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)) {