aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-12-09 16:56:56 +0100
committerregnat <rg@regnat.ovh>2020-12-11 21:17:23 +0100
commitbab1cda0e6c30e25460b5a9c809589d3948f35df (patch)
tree4418501c6be637b4049d34c0a132db2a9a8ddeaf /src/libstore/build
parent8914e01e37ad072d940e2000fede7c2e0f4b194c (diff)
Use the hash modulo in the derivation outputs
Rather than storing the derivation outputs as `drvPath!outputName` internally, store them as `drvHashModulo!outputName` (or `outputHash!outputName` for fixed-output derivations). This makes the storage slightly more opaque, but enables an earlier cutoff in cases where a fixed-output dependency changes (but keeps the same output hash) − same as what we already do for input-addressed derivations.
Diffstat (limited to 'src/libstore/build')
-rw-r--r--src/libstore/build/derivation-goal.cc28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index b7bf866eb..54b37553a 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -504,9 +504,6 @@ void DerivationGoal::inputsRealised()
Derivation drvResolved { *std::move(attempt) };
auto pathResolved = writeDerivation(worker.store, drvResolved);
- /* Add to memotable to speed up downstream goal's queries with the
- original derivation. */
- drvPathResolutions.lock()->insert_or_assign(drvPath, pathResolved);
auto msg = fmt("Resolved derivation: '%s' -> '%s'",
worker.store.printStorePath(drvPath),
@@ -2097,15 +2094,15 @@ struct RestrictedStore : public LocalFSStore, public virtual RestrictedStoreConf
void registerDrvOutput(const Realisation & info) override
{
- if (!goal.isAllowed(info.id.drvPath))
- throw InvalidPath("cannot register unknown drv output '%s' in recursive Nix", printStorePath(info.id.drvPath));
+ // XXX: Should we check for something here? Probably, but I'm not sure
+ // how
next->registerDrvOutput(info);
}
std::optional<const Realisation> queryRealisation(const DrvOutput & id) override
{
- if (!goal.isAllowed(id.drvPath))
- throw InvalidPath("cannot query the output info for unknown derivation '%s' in recursive Nix", printStorePath(id.drvPath));
+ // XXX: Should we check for something here? Probably, but I'm not sure
+ // how
return next->queryRealisation(id);
}
@@ -3394,23 +3391,14 @@ void DerivationGoal::registerOutputs()
means it's safe to link the derivation to the output hash. We must do
that for floating CA derivations, which otherwise couldn't be cached,
but it's fine to do in all cases. */
- bool isCaFloating = drv->type() == DerivationType::CAFloating;
- auto drvPathResolved = drvPath;
- if (!useDerivation && isCaFloating) {
- /* Once a floating CA derivations reaches this point, it
- must already be resolved, so we don't bother trying to
- downcast drv to get would would just be an empty
- inputDrvs field. */
- Derivation drv2 { *drv };
- drvPathResolved = writeDerivation(worker.store, drv2);
- }
-
- if (settings.isExperimentalFeatureEnabled("ca-derivations"))
+ if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
+ auto outputHashes = staticOutputHashes(worker.store, *drv);
for (auto& [outputName, newInfo] : infos)
worker.store.registerDrvOutput(Realisation{
- .id = DrvOutput{drvPathResolved, outputName},
+ .id = DrvOutput{outputHashes.at(outputName), outputName},
.outPath = newInfo.path});
+ }
}