1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 07:33:16 +02:00

Merge pull request #4732 from NixOS/4725-always-register-the-realisations

Aways register the realisations
This commit is contained in:
Eelco Dolstra 2021-04-23 14:22:03 +02:00 committed by GitHub
commit 4549d65b4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 15 deletions

View file

@ -736,18 +736,9 @@ std::set<RealisedPath> toRealisedPaths(
output.first);
auto outputId = DrvOutput{outputHashes.at(output.first), output.first};
auto realisation = store->queryRealisation(outputId);
if (!realisation) {
// TODO: remove this check once #4725 is fixed
// as well have the guaranty that if
// `output.second` exists, then the realisation
// will be there too
if (output.second)
res.insert(*output.second);
else
throw Error("cannot operate on an output of unbuilt content-addresed derivation '%s'", outputId.to_string());
} else {
res.insert(RealisedPath{*realisation});
}
if (!realisation)
throw Error("cannot operate on an output of unbuilt content-addresed derivation '%s'", outputId.to_string());
res.insert(RealisedPath{*realisation});
}
else {
// If ca-derivations isn't enabled, behave as if

View file

@ -1269,12 +1269,23 @@ void DerivationGoal::checkPathValidity()
};
}
if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
if (auto real = worker.store.queryRealisation(
DrvOutput{initialOutputs.at(i.first).outputHash, i.first})) {
auto drvOutput = DrvOutput{initialOutputs.at(i.first).outputHash, i.first};
if (auto real = worker.store.queryRealisation(drvOutput)) {
info.known = {
.path = real->outPath,
.status = PathStatus::Valid,
};
} else if (info.known && info.known->status == PathStatus::Valid) {
// We know the output because it' a static output of the
// derivation, and the output path is valid, but we don't have
// its realisation stored (probably because it has been built
// without the `ca-derivations` experimental flag)
worker.store.registerDrvOutput(
Realisation{
drvOutput,
info.known->path,
}
);
}
}
}