1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-14 04:51:05 +01:00

Combine DerivationBuilder::{prepareBuild,startBuilder}

After many other cleanups, it turns out there is no reason for these to
be separate methods. We can combine them to simplify things.
This commit is contained in:
John Ericson 2025-09-03 17:58:50 -04:00
parent 14c206f05a
commit 2acb9559d5
3 changed files with 33 additions and 41 deletions

View file

@ -689,6 +689,8 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
#else
assert(!hook);
Descriptor builderOut;
// Will continue here while waiting for a build user below
while (true) {
@ -781,7 +783,17 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
});
}
if (!builder->prepareBuild()) {
std::optional<Descriptor> builderOutOpt;
try {
/* Okay, we have to build. */
builderOutOpt = builder->startBuild();
} catch (BuildError & e) {
builder.reset();
outputLocks.unlock();
worker.permanentFailure = true;
co_return doneFailure(std::move(e)); // InputRejected
}
if (!builderOutOpt) {
if (!actLock)
actLock = std::make_unique<Activity>(
*logger,
@ -790,26 +802,15 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
fmt("waiting for a free build user ID for '%s'", Magenta(worker.store.printStorePath(drvPath))));
co_await waitForAWhile();
continue;
}
} else {
builderOut = *std::move(builderOutOpt);
};
break;
}
actLock.reset();
Descriptor builderOut;
try {
/* Okay, we have to build. */
builderOut = builder->startBuilder();
} catch (BuildError & e) {
builder.reset();
outputLocks.unlock();
worker.permanentFailure = true;
co_return doneFailure(std::move(e)); // InputRejected
}
worker.childStarted(shared_from_this(), {builderOut}, true, true);
started();