Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check-meta: don't execute check-meta.nix 15,000 times #59323

Merged
merged 1 commit into from Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkgs/stdenv/generic/check-meta.nix
@@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
};

Expand Down
16 changes: 9 additions & 7 deletions pkgs/stdenv/generic/make-derivation.nix
@@ -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.
#
Expand Down Expand Up @@ -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
Expand Down