Merge pull request #269546 from adisbladis/stdenv-meta-no-intermediate-alloc

stdenv: Avoid allocating intermediate attrset when checking meta validity
This commit is contained in:
adisbladis 2023-12-12 10:57:44 +13:00 committed by GitHub
commit 1e66093cca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -492,16 +492,21 @@ let
assertValidity = { meta, attrs }: let
validity = checkValidity attrs;
in validity // {
inherit (validity) valid;
in validity // {
# Throw an error if trying to evaluate a non-valid derivation
# or, alternatively, just output a warning message.
handled =
{
no = handleEvalIssue { inherit meta attrs; } { inherit (validity) reason errormsg; };
warn = handleEvalWarning { inherit meta attrs; } { inherit (validity) reason errormsg; };
yes = true;
}.${validity.valid};
(
if valid == "yes" then true
else if valid == "no" then (
handleEvalIssue { inherit meta attrs; } { inherit (validity) reason errormsg; }
)
else if valid == "warn" then (
handleEvalWarning { inherit meta attrs; } { inherit (validity) reason errormsg; }
)
else throw "Unknown validitiy: '${valid}'"
);
};
in { inherit assertValidity commonMeta; }