stdenv: Clean up check meta args

This commit is contained in:
John Ericson 2018-01-30 22:10:34 -05:00
parent f79f80dbf2
commit 4c52e34ca6
2 changed files with 13 additions and 14 deletions

View File

@ -1,11 +1,9 @@
# Checks derivation meta and attrs for problems (like brokenness, # Checks derivation meta and attrs for problems (like brokenness,
# licenses, etc). # licenses, etc).
{ lib, config, system, meta, derivationArg, mkDerivationArg }: { lib, config, system, meta }:
let let
attrs = mkDerivationArg; # TODO: probably get rid of passing this one
# See discussion at https://github.com/NixOS/nixpkgs/pull/25304#issuecomment-298385426 # See discussion at https://github.com/NixOS/nixpkgs/pull/25304#issuecomment-298385426
# for why this defaults to false, but I (@copumpkin) want to default it to true soon. # for why this defaults to false, but I (@copumpkin) want to default it to true soon.
shouldCheckMeta = config.checkMeta or false; shouldCheckMeta = config.checkMeta or false;
@ -123,7 +121,7 @@ let
''; '';
handleEvalIssue = { reason , errormsg ? "" }: handleEvalIssue = attrs: { reason , errormsg ? "" }:
let let
msg = '' msg = ''
Package ${attrs.name or "«name-missing»"} in ${pos_str} ${errormsg}, refusing to evaluate. Package ${attrs.name or "«name-missing»"} in ${pos_str} ${errormsg}, refusing to evaluate.
@ -196,11 +194,13 @@ let
{ valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; } { valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; }
else { valid = true; }; else { valid = true; };
assertValidity = attrs: let
validity = checkValidity attrs; validity = checkValidity attrs;
in validity // {
in validity // {
# Throw an error if trying to evaluate an non-valid derivation # Throw an error if trying to evaluate an non-valid derivation
handled = if !validity.valid handled = if !validity.valid
then handleEvalIssue (removeAttrs validity ["valid"]) then handleEvalIssue attrs (removeAttrs validity ["valid"])
else true; else true;
} };
in assertValidity

View File

@ -204,12 +204,11 @@ rec {
}); });
validity = import ./check-meta.nix { validity = import ./check-meta.nix {
inherit lib config meta derivationArg; inherit lib config meta;
mkDerivationArg = attrs;
# Nix itself uses the `system` field of a derivation to decide where # Nix itself uses the `system` field of a derivation to decide where
# to build it. This is a bit confusing for cross compilation. # to build it. This is a bit confusing for cross compilation.
inherit (stdenv) system; inherit (stdenv) system;
}; } attrs;
# The meta attribute is passed in the resulting attribute set, # The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not # but it's not part of the actual derivation, i.e., it's not