Merge pull request #59323 from grahamc/faster-check-env

check-meta: don't execute check-meta.nix 15,000 times
This commit is contained in:
Graham Christensen 2019-04-11 19:44:46 -04:00 committed by GitHub
commit 59faac3a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 13 deletions

View File

@ -1,7 +1,7 @@
# Checks derivation meta and attrs for problems (like brokenness, # Checks derivation meta and attrs for problems (like brokenness,
# licenses, etc). # licenses, etc).
{ lib, config, hostPlatform, meta }: { lib, config, hostPlatform }:
let let
# If we're in hydra, we can dispense with the more verbose error # If we're in hydra, we can dispense with the more verbose error
@ -76,7 +76,7 @@ let
showLicense = license: license.shortName or "unknown"; showLicense = license: license.shortName or "unknown";
pos_str = meta.position or "«unknown-file»"; pos_str = meta: meta.position or "«unknown-file»";
remediation = { remediation = {
unfree = remediate_whitelist "Unfree"; unfree = remediate_whitelist "Unfree";
@ -143,12 +143,12 @@ let
${lib.concatStrings (builtins.map (output: " - ${output}\n") missingOutputs)} ${lib.concatStrings (builtins.map (output: " - ${output}\n") missingOutputs)}
''; '';
handleEvalIssue = attrs: { reason , errormsg ? "" }: handleEvalIssue = { meta, attrs }: { reason , errormsg ? "" }:
let let
msg = if inHydra msg = if inHydra
then "Failed to evaluate ${attrs.name or "«name-missing»"}: «${reason}»: ${errormsg}" then "Failed to evaluate ${attrs.name or "«name-missing»"}: «${reason}»: ${errormsg}"
else '' else ''
Package ${attrs.name or "«name-missing»"} in ${pos_str} ${errormsg}, refusing to evaluate. Package ${attrs.name or "«name-missing»"} in ${pos_str meta} ${errormsg}, refusing to evaluate.
'' + (builtins.getAttr reason remediation) attrs; '' + (builtins.getAttr reason remediation) attrs;
@ -245,12 +245,12 @@ 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 assertValidity = { meta, 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 attrs (removeAttrs validity ["valid"]) then handleEvalIssue { inherit meta attrs; } (removeAttrs validity ["valid"])
else true; else true;
}; };

View File

@ -1,6 +1,13 @@
{ lib, config, stdenv }: { lib, config, stdenv }:
rec { let
checkMeta = import ./check-meta.nix {
inherit lib config;
# Nix itself uses the `system` field of a derivation to decide where
# to build it. This is a bit confusing for cross compilation.
inherit (stdenv) hostPlatform;
};
in rec {
# `mkDerivation` wraps the builtin `derivation` function to # `mkDerivation` wraps the builtin `derivation` function to
# produce derivations that use this stdenv and its shell. # produce derivations that use this stdenv and its shell.
# #
@ -263,12 +270,7 @@ rec {
__propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps; __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps;
}; };
validity = import ./check-meta.nix { validity = checkMeta { inherit meta attrs; };
inherit lib config meta;
# Nix itself uses the `system` field of a derivation to decide where
# to build it. This is a bit confusing for cross compilation.
inherit (stdenv) hostPlatform;
} 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