mirror of
https://github.com/NixOS/nix.git
synced 2025-12-12 20:11:03 +01:00
Get rid of delayedException in DerivationBuilder
Instead of that funny business, the fixed output checks are not put in `checkOutputs`, with the other (newer) output checks, where they also better belong. The control flow is reworked (with comments!) so that `checkOutputs` also runs in the `bmCheck` case. Not only does this preserve existing behavior of `bmCheck` double-checking fixed output hashes with less tricky code, it also makes `bmCheck` better by also double-checking the other output checks, rather than just assuming they pass if the derivation is deterministic.
This commit is contained in:
parent
ff961fd9e2
commit
0b85b023d8
3 changed files with 109 additions and 104 deletions
|
|
@ -10,6 +10,7 @@ namespace nix {
|
|||
void checkOutputs(
|
||||
Store & store,
|
||||
const StorePath & drvPath,
|
||||
const decltype(Derivation::outputs) & drvOutputs,
|
||||
const decltype(DerivationOptions::outputChecks) & outputChecks,
|
||||
const std::map<std::string, ValidPathInfo> & outputs)
|
||||
{
|
||||
|
|
@ -17,9 +18,37 @@ void checkOutputs(
|
|||
for (auto & output : outputs)
|
||||
outputsByPath.emplace(store.printStorePath(output.second.path), output.second);
|
||||
|
||||
for (auto & output : outputs) {
|
||||
auto & outputName = output.first;
|
||||
auto & info = output.second;
|
||||
for (auto & [outputName, info] : outputs) {
|
||||
|
||||
auto * outputSpec = get(drvOutputs, outputName);
|
||||
assert(outputSpec);
|
||||
|
||||
if (const auto * dof = std::get_if<DerivationOutput::CAFixed>(&outputSpec->raw)) {
|
||||
auto & wanted = dof->ca.hash;
|
||||
|
||||
/* Check wanted hash */
|
||||
assert(info.ca);
|
||||
auto & got = info.ca->hash;
|
||||
if (wanted != got) {
|
||||
/* Throw an error after registering the path as
|
||||
valid. */
|
||||
throw BuildError(
|
||||
BuildResult::HashMismatch,
|
||||
"hash mismatch in fixed-output derivation '%s':\n specified: %s\n got: %s",
|
||||
store.printStorePath(drvPath),
|
||||
wanted.to_string(HashFormat::SRI, true),
|
||||
got.to_string(HashFormat::SRI, true));
|
||||
}
|
||||
if (!info.references.empty()) {
|
||||
auto numViolations = info.references.size();
|
||||
throw BuildError(
|
||||
BuildResult::HashMismatch,
|
||||
"fixed-output derivations must not reference store paths: '%s' references %d distinct paths, e.g. '%s'",
|
||||
store.printStorePath(drvPath),
|
||||
numViolations,
|
||||
store.printStorePath(*info.references.begin()));
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute the closure and closure size of some output. This
|
||||
is slightly tricky because some of its references (namely
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue