mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
DerivationBuildingGoal::initialOutputs move initialization down to tryToBuild
Will help us make this a local variable.
This commit is contained in:
parent
450633aa8c
commit
c0c2a89f05
1 changed files with 29 additions and 28 deletions
|
|
@ -127,31 +127,6 @@ static void runPostBuildHook(
|
||||||
produced using a substitute. So we have to build instead. */
|
produced using a substitute. So we have to build instead. */
|
||||||
Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
|
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{.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;
|
Goals waitees;
|
||||||
|
|
||||||
std::map<ref<const SingleDerivedPath>, GoalPtr, value_comparison> inputGoals;
|
std::map<ref<const SingleDerivedPath>, GoalPtr, value_comparison> inputGoals;
|
||||||
|
|
@ -334,14 +309,15 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
|
||||||
if (resolvedResult.success()) {
|
if (resolvedResult.success()) {
|
||||||
SingleDrvOutputs builtOutputs;
|
SingleDrvOutputs builtOutputs;
|
||||||
|
|
||||||
|
auto outputHashes = staticOutputHashes(worker.evalStore, *drv);
|
||||||
auto resolvedHashes = staticOutputHashes(worker.store, drvResolved);
|
auto resolvedHashes = staticOutputHashes(worker.store, drvResolved);
|
||||||
|
|
||||||
StorePathSet outputPaths;
|
StorePathSet outputPaths;
|
||||||
|
|
||||||
for (auto & outputName : drvResolved.outputNames()) {
|
for (auto & outputName : drvResolved.outputNames()) {
|
||||||
auto initialOutput = get(initialOutputs, outputName);
|
auto outputHash = get(outputHashes, outputName);
|
||||||
auto resolvedHash = get(resolvedHashes, outputName);
|
auto resolvedHash = get(resolvedHashes, outputName);
|
||||||
if ((!initialOutput) || (!resolvedHash))
|
if ((!outputHash) || (!resolvedHash))
|
||||||
throw Error(
|
throw Error(
|
||||||
"derivation '%s' doesn't have expected output '%s' (derivation-goal.cc/resolve)",
|
"derivation '%s' doesn't have expected output '%s' (derivation-goal.cc/resolve)",
|
||||||
worker.store.printStorePath(drvPath),
|
worker.store.printStorePath(drvPath),
|
||||||
|
|
@ -368,7 +344,7 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
|
||||||
|
|
||||||
if (!drv->type().isImpure()) {
|
if (!drv->type().isImpure()) {
|
||||||
auto newRealisation = realisation;
|
auto newRealisation = realisation;
|
||||||
newRealisation.id = DrvOutput{initialOutput->outputHash, outputName};
|
newRealisation.id = DrvOutput{*outputHash, outputName};
|
||||||
newRealisation.signatures.clear();
|
newRealisation.signatures.clear();
|
||||||
if (!drv->type().isFixed()) {
|
if (!drv->type().isFixed()) {
|
||||||
auto & drvStore = worker.evalStore.isValidPath(drvPath) ? worker.evalStore : worker.store;
|
auto & drvStore = worker.evalStore.isValidPath(drvPath) ? worker.evalStore : worker.store;
|
||||||
|
|
@ -441,6 +417,31 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
|
||||||
|
|
||||||
Goal::Co DerivationBuildingGoal::tryToBuild()
|
Goal::Co DerivationBuildingGoal::tryToBuild()
|
||||||
{
|
{
|
||||||
|
/* 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{.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();
|
||||||
|
|
||||||
auto started = [&]() {
|
auto started = [&]() {
|
||||||
auto msg =
|
auto msg =
|
||||||
fmt(buildMode == bmRepair ? "repairing outputs of '%s'"
|
fmt(buildMode == bmRepair ? "repairing outputs of '%s'"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue