Ensure resolved CA derivations are written
so we can link outputs to deriver and thus properly cache.
This commit is contained in:
parent
7fdbb377ba
commit
2741fffa35
2 changed files with 21 additions and 13 deletions
|
@ -4298,11 +4298,13 @@ void DerivationGoal::registerOutputs()
|
||||||
/* Register each output path as valid, and register the sets of
|
/* Register each output path as valid, and register the sets of
|
||||||
paths referenced by each of them. If there are cycles in the
|
paths referenced by each of them. If there are cycles in the
|
||||||
outputs, this will fail. */
|
outputs, this will fail. */
|
||||||
|
{
|
||||||
ValidPathInfos infos2;
|
ValidPathInfos infos2;
|
||||||
for (auto & [outputName, newInfo] : infos) {
|
for (auto & [outputName, newInfo] : infos) {
|
||||||
infos2.push_back(newInfo);
|
infos2.push_back(newInfo);
|
||||||
}
|
}
|
||||||
worker.store.registerValidPaths(infos2);
|
worker.store.registerValidPaths(infos2);
|
||||||
|
}
|
||||||
|
|
||||||
/* In case of a fixed-output derivation hash mismatch, throw an
|
/* In case of a fixed-output derivation hash mismatch, throw an
|
||||||
exception now that we have registered the output as valid. */
|
exception now that we have registered the output as valid. */
|
||||||
|
@ -4314,16 +4316,21 @@ void DerivationGoal::registerOutputs()
|
||||||
means it's safe to link the derivation to the output hash. We must do
|
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,
|
that for floating CA derivations, which otherwise couldn't be cached,
|
||||||
but it's fine to do in all cases. */
|
but it's fine to do in all cases. */
|
||||||
for (auto & [outputName, newInfo] : infos) {
|
bool isCaFloating = drv->type() == DerivationType::CAFloating;
|
||||||
if (useDerivation)
|
|
||||||
|
auto drvPath2 = 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 };
|
||||||
|
drvPath2 = writeDerivation(worker.store, drv2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useDerivation || isCaFloating)
|
||||||
|
for (auto & [outputName, newInfo] : infos)
|
||||||
worker.store.linkDeriverToPath(drvPath, outputName, newInfo.path);
|
worker.store.linkDeriverToPath(drvPath, outputName, newInfo.path);
|
||||||
else {
|
|
||||||
/* Once a floating CA derivations reaches this point, it must
|
|
||||||
already be resolved, drvPath the basic derivation path, and
|
|
||||||
a file existsing at that path for sake of the DB's foreign key. */
|
|
||||||
assert(drv->type() != DerivationType::CAFloating);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ struct Derivation : BasicDerivation
|
||||||
std::optional<BasicDerivation> tryResolve(Store & store);
|
std::optional<BasicDerivation> tryResolve(Store & store);
|
||||||
|
|
||||||
Derivation() = default;
|
Derivation() = default;
|
||||||
|
Derivation(const BasicDerivation & bd) : BasicDerivation(bd) { }
|
||||||
Derivation(BasicDerivation && bd) : BasicDerivation(std::move(bd)) { }
|
Derivation(BasicDerivation && bd) : BasicDerivation(std::move(bd)) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue