1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 12:06:01 +01:00

DerivationGoal Make some fields immutable

We can set both during construction, yay!
This commit is contained in:
John Ericson 2025-08-14 00:39:00 -04:00
parent f155dffe59
commit 4a2de1dbab
2 changed files with 11 additions and 9 deletions

View file

@ -33,7 +33,13 @@ DerivationGoal::DerivationGoal(
: Goal(worker, haveDerivation())
, drvPath(drvPath)
, wantedOutput(wantedOutput)
, outputHash{Hash::dummy} // will be updated
, outputHash{[&] {
if (auto * mOutputHash = get(staticOutputHashes(worker.evalStore, drv), wantedOutput))
return *mOutputHash;
else
throw Error(
"derivation '%s' does not have output '%s'", worker.store.printStorePath(drvPath), wantedOutput);
}()}
, buildMode(buildMode)
{
this->drv = std::make_unique<Derivation>(drv);
@ -79,10 +85,6 @@ Goal::Co DerivationGoal::haveDerivation()
if (i.second.second)
worker.store.addTempRoot(*i.second.second);
if (auto * mOutputHash = get(staticOutputHashes(worker.evalStore, *drv), wantedOutput)) {
outputHash = *mOutputHash;
}
/* We don't yet have any safe way to cache an impure derivation at
this step. */
if (drv->type().isImpure()) {

View file

@ -70,14 +70,14 @@ private:
*/
std::unique_ptr<Derivation> drv;
const Hash outputHash;
const BuildMode buildMode;
/**
* The remainder is state held during the build.
*/
Hash outputHash;
BuildMode buildMode;
std::unique_ptr<MaintainCount<uint64_t>> mcExpectedBuilds;
/**