mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 20:16:03 +01:00
Don't use InitialOutput in DerivationGoal
We don't need the `wanted` field. Just inline the other two fields.
This commit is contained in:
parent
14173d761c
commit
1a6f92837a
2 changed files with 23 additions and 23 deletions
|
|
@ -24,16 +24,17 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
DerivationGoal::DerivationGoal(const StorePath & drvPath, const Derivation & drv,
|
DerivationGoal::DerivationGoal(
|
||||||
const OutputName & wantedOutput, Worker & worker, BuildMode buildMode)
|
const StorePath & drvPath,
|
||||||
|
const Derivation & drv,
|
||||||
|
const OutputName & wantedOutput,
|
||||||
|
Worker & worker,
|
||||||
|
BuildMode buildMode)
|
||||||
: Goal(worker, haveDerivation())
|
: Goal(worker, haveDerivation())
|
||||||
, drvPath(drvPath)
|
, drvPath(drvPath)
|
||||||
, wantedOutput(wantedOutput)
|
, wantedOutput(wantedOutput)
|
||||||
, initialOutput{
|
, outputHash{Hash::dummy} // will be updated
|
||||||
.wanted = true,
|
, outputKnown{}
|
||||||
.outputHash = Hash::dummy, // will be updated
|
|
||||||
.known = {},
|
|
||||||
}
|
|
||||||
, buildMode(buildMode)
|
, buildMode(buildMode)
|
||||||
{
|
{
|
||||||
this->drv = std::make_unique<Derivation>(drv);
|
this->drv = std::make_unique<Derivation>(drv);
|
||||||
|
|
@ -129,19 +130,18 @@ Goal::Co DerivationGoal::haveDerivation()
|
||||||
if (outputName != wantedOutput)
|
if (outputName != wantedOutput)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
InitialOutput v{.wanted = true, .outputHash = outputHash};
|
this->outputHash = outputHash;
|
||||||
|
|
||||||
/* TODO we might want to also allow randomizing the paths
|
/* TODO we might want to also allow randomizing the paths
|
||||||
for regular CA derivations, e.g. for sake of checking
|
for regular CA derivations, e.g. for sake of checking
|
||||||
determinism. */
|
determinism. */
|
||||||
if (impure) {
|
if (impure) {
|
||||||
v.known = InitialOutputStatus{
|
outputKnown = InitialOutputStatus{
|
||||||
.path = StorePath::random(outputPathName(drv->name, outputName)),
|
.path = StorePath::random(outputPathName(drv->name, outputName)),
|
||||||
.status = PathStatus::Absent,
|
.status = PathStatus::Absent,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
initialOutput = std::move(v);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,13 +168,13 @@ Goal::Co DerivationGoal::haveDerivation()
|
||||||
through substitutes. If that doesn't work, we'll build
|
through substitutes. If that doesn't work, we'll build
|
||||||
them. */
|
them. */
|
||||||
if (settings.useSubstitutes && drvOptions.substitutesAllowed()) {
|
if (settings.useSubstitutes && drvOptions.substitutesAllowed()) {
|
||||||
if (!initialOutput.known)
|
if (!outputKnown)
|
||||||
waitees.insert(upcast_goal(worker.makeDrvOutputSubstitutionGoal(
|
waitees.insert(upcast_goal(worker.makeDrvOutputSubstitutionGoal(
|
||||||
DrvOutput{initialOutput.outputHash, wantedOutput}, buildMode == bmRepair ? Repair : NoRepair)));
|
DrvOutput{outputHash, wantedOutput}, buildMode == bmRepair ? Repair : NoRepair)));
|
||||||
else {
|
else {
|
||||||
auto * cap = getDerivationCA(*drv);
|
auto * cap = getDerivationCA(*drv);
|
||||||
waitees.insert(upcast_goal(worker.makePathSubstitutionGoal(
|
waitees.insert(upcast_goal(worker.makePathSubstitutionGoal(
|
||||||
initialOutput.known->path,
|
outputKnown->path,
|
||||||
buildMode == bmRepair ? Repair : NoRepair,
|
buildMode == bmRepair ? Repair : NoRepair,
|
||||||
cap ? std::optional{*cap} : std::nullopt)));
|
cap ? std::optional{*cap} : std::nullopt)));
|
||||||
}
|
}
|
||||||
|
|
@ -330,24 +330,23 @@ std::pair<bool, SingleDrvOutputs> DerivationGoal::checkPathValidity()
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (auto * mpath = get(partialDerivationOutputMap, wantedOutput)) {
|
if (auto * mpath = get(partialDerivationOutputMap, wantedOutput)) {
|
||||||
auto & info = initialOutput;
|
|
||||||
if (*mpath) {
|
if (*mpath) {
|
||||||
auto & outputPath = **mpath;
|
auto & outputPath = **mpath;
|
||||||
info.known = {
|
outputKnown = {
|
||||||
.path = outputPath,
|
.path = outputPath,
|
||||||
.status = !worker.store.isValidPath(outputPath) ? PathStatus::Absent
|
.status = !worker.store.isValidPath(outputPath) ? PathStatus::Absent
|
||||||
: !checkHash || worker.pathContentsGood(outputPath) ? PathStatus::Valid
|
: !checkHash || worker.pathContentsGood(outputPath) ? PathStatus::Valid
|
||||||
: PathStatus::Corrupt,
|
: PathStatus::Corrupt,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
auto drvOutput = DrvOutput{info.outputHash, wantedOutput};
|
auto drvOutput = DrvOutput{outputHash, wantedOutput};
|
||||||
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
||||||
if (auto real = worker.store.queryRealisation(drvOutput)) {
|
if (auto real = worker.store.queryRealisation(drvOutput)) {
|
||||||
info.known = {
|
outputKnown = {
|
||||||
.path = real->outPath,
|
.path = real->outPath,
|
||||||
.status = PathStatus::Valid,
|
.status = PathStatus::Valid,
|
||||||
};
|
};
|
||||||
} else if (info.known && info.known->isValid()) {
|
} else if (outputKnown && outputKnown->isValid()) {
|
||||||
// We know the output because it's a static output of the
|
// We know the output because it's a static output of the
|
||||||
// derivation, and the output path is valid, but we don't have
|
// derivation, and the output path is valid, but we don't have
|
||||||
// its realisation stored (probably because it has been built
|
// its realisation stored (probably because it has been built
|
||||||
|
|
@ -355,12 +354,12 @@ std::pair<bool, SingleDrvOutputs> DerivationGoal::checkPathValidity()
|
||||||
worker.store.registerDrvOutput(
|
worker.store.registerDrvOutput(
|
||||||
Realisation{
|
Realisation{
|
||||||
drvOutput,
|
drvOutput,
|
||||||
info.known->path,
|
outputKnown->path,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (info.known && info.known->isValid())
|
if (outputKnown && outputKnown->isValid())
|
||||||
validOutputs.emplace(wantedOutput, Realisation{drvOutput, info.known->path});
|
validOutputs.emplace(wantedOutput, Realisation{drvOutput, outputKnown->path});
|
||||||
} else {
|
} else {
|
||||||
// If we requested all the outputs, we are always fine.
|
// If we requested all the outputs, we are always fine.
|
||||||
// If we requested specific elements, the loop above removes all the valid
|
// If we requested specific elements, the loop above removes all the valid
|
||||||
|
|
@ -371,7 +370,7 @@ std::pair<bool, SingleDrvOutputs> DerivationGoal::checkPathValidity()
|
||||||
|
|
||||||
bool allValid = true;
|
bool allValid = true;
|
||||||
{
|
{
|
||||||
if (!initialOutput.known || !initialOutput.known->isValid()) {
|
if (!outputKnown || !outputKnown->isValid()) {
|
||||||
allValid = false;
|
allValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,8 @@ private:
|
||||||
* The remainder is state held during the build.
|
* The remainder is state held during the build.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
InitialOutput initialOutput;
|
Hash outputHash;
|
||||||
|
std::optional<InitialOutputStatus> outputKnown;
|
||||||
|
|
||||||
BuildMode buildMode;
|
BuildMode buildMode;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue