Use member initializer list for Derivation*Goal::drv

This commit is contained in:
John Ericson
2025-10-11 18:36:29 -04:00
parent ba7bbcd1da
commit a629ce3dec
2 changed files with 4 additions and 5 deletions

View File

@@ -27,16 +27,15 @@
namespace nix {
DerivationBuildingGoal::DerivationBuildingGoal(
const StorePath & drvPath, const Derivation & drv_, Worker & worker, BuildMode buildMode)
const StorePath & drvPath, const Derivation & drv, Worker & worker, BuildMode buildMode)
: Goal(worker, gaveUpOnSubstitution())
, drvPath(drvPath)
, drv{std::make_unique<Derivation>(drv)}
, buildMode(buildMode)
{
drv = std::make_unique<Derivation>(drv_);
try {
drvOptions =
std::make_unique<DerivationOptions>(DerivationOptions::fromStructuredAttrs(drv->env, drv->structuredAttrs));
std::make_unique<DerivationOptions>(DerivationOptions::fromStructuredAttrs(drv.env, drv.structuredAttrs));
} catch (Error & e) {
e.addTrace({}, "while parsing derivation '%s'", worker.store.printStorePath(drvPath));
throw;

View File

@@ -33,6 +33,7 @@ DerivationGoal::DerivationGoal(
: Goal(worker, haveDerivation())
, drvPath(drvPath)
, wantedOutput(wantedOutput)
, drv{std::make_unique<Derivation>(drv)}
, outputHash{[&] {
auto outputHashes = staticOutputHashes(worker.evalStore, drv);
if (auto * mOutputHash = get(outputHashes, wantedOutput))
@@ -41,7 +42,6 @@ DerivationGoal::DerivationGoal(
}()}
, buildMode(buildMode)
{
this->drv = std::make_unique<Derivation>(drv);
name = fmt("getting output '%s' from derivation '%s'", wantedOutput, worker.store.printStorePath(drvPath));
trace("created");