Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d2803406b527
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 20ea1de77d92
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Feb 23, 2021

  1. Make DerivationGoal::drv a full Derivation

    This field used to be a `BasicDerivation`, but this `BasicDerivation`
    was downcasted to a `Derivation` when needed (implicitely or not), so we
    might as well make it a full `Derivation` and upcast it when needed.
    
    This also allows getting rid of a weird duplication in the way we
    compute the static output hashes for the derivation. We had to
    do it differently and in a different place depending on whether the
    derivation was a full derivation or just a basic drv, but we can now do
    it unconditionally on the full derivation.
    
    Fix #4559
    thufschmitt committed Feb 23, 2021
    Copy the full SHA
    ba1a256 View commit details

Commits on Feb 26, 2021

  1. Copy the full SHA
    73daffb View commit details
  2. Use std::make_unique

    edolstra committed Feb 26, 2021
    Copy the full SHA
    20ea1de View commit details
Showing with 14 additions and 27 deletions.
  1. +13 −26 src/libstore/build/derivation-goal.cc
  2. +1 −1 src/libstore/build/derivation-goal.hh
39 changes: 13 additions & 26 deletions src/libstore/build/derivation-goal.cc
Original file line number Diff line number Diff line change
@@ -123,17 +123,7 @@ DerivationGoal::DerivationGoal(const StorePath & drvPath, const BasicDerivation
, wantedOutputs(wantedOutputs)
, buildMode(buildMode)
{
this->drv = std::make_unique<BasicDerivation>(BasicDerivation(drv));

auto outputHashes = staticOutputHashes(worker.store, drv);
for (auto &[outputName, outputHash] : outputHashes)
initialOutputs.insert({
outputName,
InitialOutput{
.wanted = true, // Will be refined later
.outputHash = outputHash
}
});
this->drv = std::make_unique<Derivation>(drv);

state = &DerivationGoal::haveDerivation;
name = fmt(
@@ -269,20 +259,8 @@ void DerivationGoal::loadDerivation()

assert(worker.store.isValidPath(drvPath));

auto fullDrv = new Derivation(worker.store.derivationFromPath(drvPath));

auto outputHashes = staticOutputHashes(worker.store, *fullDrv);
for (auto &[outputName, outputHash] : outputHashes)
initialOutputs.insert({
outputName,
InitialOutput{
.wanted = true, // Will be refined later
.outputHash = outputHash
}
});

/* Get the derivation. */
drv = std::unique_ptr<BasicDerivation>(fullDrv);
drv = std::make_unique<Derivation>(worker.store.derivationFromPath(drvPath));

haveDerivation();
}
@@ -301,6 +279,16 @@ void DerivationGoal::haveDerivation()
if (i.second.second)
worker.store.addTempRoot(*i.second.second);

auto outputHashes = staticOutputHashes(worker.store, *drv);
for (auto &[outputName, outputHash] : outputHashes)
initialOutputs.insert({
outputName,
InitialOutput{
.wanted = true, // Will be refined later
.outputHash = outputHash
}
});

/* Check what outputs paths are not already valid. */
checkPathValidity();
bool allValid = true;
@@ -3517,10 +3505,9 @@ void DerivationGoal::registerOutputs()
but it's fine to do in all cases. */

if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
auto outputHashes = staticOutputHashes(worker.store, *drv);
for (auto& [outputName, newInfo] : infos)
worker.store.registerDrvOutput(Realisation{
.id = DrvOutput{outputHashes.at(outputName), outputName},
.id = DrvOutput{initialOutputs.at(outputName).outputHash, outputName},
.outPath = newInfo.path});
}
}
2 changes: 1 addition & 1 deletion src/libstore/build/derivation-goal.hh
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ struct DerivationGoal : public Goal
bool retrySubstitution;

/* The derivation stored at drvPath. */
std::unique_ptr<BasicDerivation> drv;
std::unique_ptr<Derivation> drv;

std::unique_ptr<ParsedDerivation> parsedDrv;