1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-17 07:52:43 +01:00

DerivationBuildingGoal: Check outputs beforehand

See the comment in the code for details. Some of the code is duplicated
for now, but we'll be cleaning that up soon.
This commit is contained in:
John Ericson 2025-08-13 17:36:37 -04:00
parent cf7084a67c
commit 4b6edfcfc7
2 changed files with 27 additions and 3 deletions

View file

@ -151,6 +151,33 @@ std::string showKnownOutputs(Store & store, const Derivation & drv)
produced using a substitute. So we have to build instead. */
Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
{
/* Recheck at goal start. In particular, whereas before we were
given this information by the downstream goal, that cannot happen
anymore if the downstream goal only cares about one output, but
we care about all outputs. */
auto outputHashes = staticOutputHashes(worker.evalStore, *drv);
for (auto & [outputName, outputHash] : outputHashes) {
InitialOutput v{
.wanted = true, // Will be refined later
.outputHash = outputHash};
/* TODO we might want to also allow randomizing the paths
for regular CA derivations, e.g. for sake of checking
determinism. */
if (drv->type().isImpure()) {
v.known = InitialOutputStatus{
.path = StorePath::random(outputPathName(drv->name, outputName)),
.status = PathStatus::Absent,
};
}
initialOutputs.insert({
outputName,
std::move(v),
});
}
checkPathValidity();
Goals waitees;
std::map<ref<const SingleDerivedPath>, GoalPtr, value_comparison> inputGoals;

View file

@ -82,9 +82,6 @@ Goal::Co DerivationGoal::haveDerivation()
/* We will finish with it ourselves, as if we were the derivational goal. */
g->preserveException = true;
// TODO move into constructor
g->initialOutputs = initialOutputs;
{
Goals waitees;
waitees.insert(g);