move unsafeDiscardReferences out of outputChecks

It's not a check.
This commit is contained in:
Naïm Favier 2023-01-03 18:53:01 +01:00
parent 15f7fa59be
commit 3c968191f1
No known key found for this signature in database
GPG key ID: 95AFCE8211908325
3 changed files with 9 additions and 13 deletions

View file

@ -26,7 +26,7 @@
to disable scanning a given output for runtime dependencies:
```nix
__structuredAttrs = true;
outputChecks.out.unsafeDiscardReferences = true;
unsafeDiscardReferences.out = true;
```
This is useful e.g. when generating self-contained filesystem images with
their own embedded Nix store: hashes found inside such an image refer

View file

@ -2321,14 +2321,12 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
bool discardReferences = false;
if (auto structuredAttrs = parsedDrv->getStructuredAttrs()) {
if (auto outputChecks = get(*structuredAttrs, "outputChecks")) {
if (auto output = get(*outputChecks, outputName)) {
if (auto unsafeDiscardReferences = get(*output, "unsafeDiscardReferences")) {
if (auto udr = get(*structuredAttrs, "unsafeDiscardReferences")) {
settings.requireExperimentalFeature(Xp::DiscardReferences);
if (!unsafeDiscardReferences->is_boolean())
throw Error("attribute 'outputChecks.\"%s\".unsafeDiscardReferences' of derivation '%s' must be a Boolean", outputName, drvPath.to_string());
discardReferences = unsafeDiscardReferences->get<bool>();
}
if (auto output = get(*udr, outputName)) {
if (!output->is_boolean())
throw Error("attribute 'unsafeDiscardReferences.\"%s\"' of derivation '%s' must be a Boolean", outputName, drvPath.to_string());
discardReferences = output->get<bool>();
}
}
}

View file

@ -69,10 +69,8 @@ rec {
test11 = makeTest 11 {
__structuredAttrs = true;
outputChecks.out = {
unsafeDiscardReferences = true;
allowedReferences = [];
};
unsafeDiscardReferences.out = true;
outputChecks.out.allowedReferences = [];
buildCommand = ''echo ${dep} > "''${outputs[out]}"'';
};