diff options
author | Peter Waller <p@pwaller.net> | 2023-06-30 16:11:12 +0100 |
---|---|---|
committer | Peter Waller <p@pwaller.net> | 2023-08-09 20:57:04 +0100 |
commit | 4b1bd822ac7fd35b30f37c1b7705c523cc462761 (patch) | |
tree | 22c91ef24746ea7d7f3ab423a605742e55087c3c /src/libstore/misc.cc | |
parent | d00fe5f22559efc6f8b4b92eab537b08c0e43dee (diff) |
Try to realise CA derivations during queryMissing
This enables nix to correctly report what will be fetched in the case
that everything is a cache hit.
Note however that if an intermediate build of something which is not
cached could still cause products to end up being substituted if the
intermediate build results in a CA path which is in the cache.
Fixes #8615.
Signed-off-by: Peter Waller <p@pwaller.net>
Diffstat (limited to 'src/libstore/misc.cc')
-rw-r--r-- | src/libstore/misc.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index 14160dc8b..2fdf0a68d 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -200,6 +200,36 @@ void Store::queryMissing(const std::vector<DerivedPath> & targets, auto drv = make_ref<Derivation>(derivationFromPath(bfd.drvPath)); ParsedDerivation parsedDrv(StorePath(bfd.drvPath), *drv); + if (!knownOutputPaths && settings.useSubstitutes && parsedDrv.substitutesAllowed()) { + experimentalFeatureSettings.require(Xp::CaDerivations); + + // If there are unknown output paths, attempt to find if the + // paths are known to substituters through a realisation. + auto outputHashes = staticOutputHashes(*this, *drv); + knownOutputPaths = true; + + for (auto [outputName, hash] : outputHashes) { + if (!bfd.outputs.contains(outputName)) + continue; + + bool found = false; + for (auto &sub : getDefaultSubstituters()) { + auto realisation = sub->queryRealisation({hash, outputName}); + if (!realisation) + continue; + found = true; + if (!isValidPath(realisation->outPath)) + invalid.insert(realisation->outPath); + break; + } + if (!found) { + // Some paths did not have a realisation, this must be built. + knownOutputPaths = false; + break; + } + } + } + if (knownOutputPaths && settings.useSubstitutes && parsedDrv.substitutesAllowed()) { auto drvState = make_ref<Sync<DrvState>>(DrvState(invalid.size())); for (auto & output : invalid) |