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,
# licenses, etc).
{ lib, config, hostPlatform, meta }:
{ lib, config, hostPlatform }:
let
# If we're in hydra, we can dispense with the more verbose error
@ -76,7 +76,7 @@ let
showLicense = license: license.shortName or "unknown";
pos_str = meta.position or "«unknown-file»";
pos_str = meta: meta.position or "«unknown-file»";
remediation = {
unfree = remediate_whitelist "Unfree";
@ -143,12 +143,12 @@ let
${lib.concatStrings (builtins.map (output: " - ${output}\n") missingOutputs)}
'';
handleEvalIssue = attrs: { reason , errormsg ? "" }:
handleEvalIssue = { meta, attrs }: { reason , errormsg ? "" }:
let
msg = if inHydra
then "Failed to evaluate ${attrs.name or "«name-missing»"}: «${reason}»: ${errormsg}"
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;
@ -245,12 +245,12 @@ let
{ valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; }
else { valid = true; };
assertValidity = attrs: let
assertValidity = { meta, attrs }: let
validity = checkValidity attrs;
in validity // {
# Throw an error if trying to evaluate an non-valid derivation
handled = if !validity.valid
then handleEvalIssue attrs (removeAttrs validity ["valid"])
then handleEvalIssue { inherit meta attrs; } (removeAttrs validity ["valid"])
else true;
};

View file

@ -1,6 +1,13 @@
{ 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
# produce derivations that use this stdenv and its shell.
#
@ -263,12 +270,7 @@ rec {
__propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps;
};
validity = import ./check-meta.nix {
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;
validity = checkMeta { inherit meta attrs; };
# The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not