Skip to content

Commit 4e8dff5

Browse files
committed
check-meta: Avoid expensive evaluation of output meta
Thanks for the pointer @llakala!
1 parent 69523fb commit 4e8dff5

3 files changed

Lines changed: 22 additions & 15 deletions

File tree

pkgs/stdenv/generic/check-meta.nix

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let
5252
problemsType
5353
genCheckProblems
5454
;
55-
checkProblems = genCheckProblems config;
55+
checkProblems = genCheckProblems config defaultRequiresMaintainers;
5656

5757
# If we're in hydra, we can dispense with the more verbose error
5858
# messages and make problems easier to spot.
@@ -749,10 +749,14 @@ let
749749
let
750750
checkValidity' = checkValidity hostPlatform;
751751
in
752-
{ meta, attrs }:
752+
{
753+
meta,
754+
attrs,
755+
pos ? null,
756+
}:
753757
let
754758
invalid = checkValidity' attrs;
755-
problems = checkProblems attrs meta;
759+
problems = checkProblems attrs pos;
756760
in
757761
if isNull invalid then
758762
if isNull problems then

pkgs/stdenv/generic/make-derivation.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ let
980980
++ attrs.propagatedNativeBuildInputs or [ ]
981981
++ attrs.propagatedBuildInputs or [ ];
982982
};
983-
validity = assertValidity { inherit meta attrs; };
983+
validity = assertValidity { inherit meta attrs pos; };
984984

985985
checkedEnv =
986986
let

pkgs/stdenv/generic/problems.nix

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ rec {
9696
{
9797
kindName = "maintainerless";
9898
condition =
99-
config: attrs: outputMeta:
100-
outputMeta.requiresMaintainers
99+
config: attrs: requiresMaintainers:
100+
requiresMaintainers
101101
&& (attrs.meta.maintainers or [ ] == [ ])
102102
&& (attrs.meta.teams or [ ] == [ ])
103103
&& (attrs.meta.hasNoMaintainersButDependents or false == false);
@@ -117,20 +117,20 @@ rec {
117117
config.allowBrokenPredicate;
118118
in
119119
if allowBroken then
120-
attrs: outputMeta: false
120+
attrs: requiresMaintainers: false
121121
else if config ? allowBrokenPredicate then
122-
attrs: outputMeta: attrs ? meta.broken && attrs.meta.broken && !allowBrokenPredicate attrs
122+
attrs: requiresMaintainers: attrs ? meta.broken && attrs.meta.broken && !allowBrokenPredicate attrs
123123
else
124-
attrs: outputMeta: attrs ? meta.broken && attrs.meta.broken;
124+
attrs: requiresMaintainers: attrs ? meta.broken && attrs.meta.broken;
125125
value.message = "This package is broken.";
126126
}
127127
];
128128

129129
genAutomaticProblems =
130-
config: attrs: outputMeta:
130+
config: attrs: requiresMaintainers:
131131
listToAttrs (
132132
map (problem: lib.nameValuePair problem.kindName problem.value) (
133-
filter (problem: problem.condition config attrs outputMeta) automaticProblems
133+
filter (problem: problem.condition config attrs requiresMaintainers) automaticProblems
134134
)
135135
);
136136

@@ -446,7 +446,7 @@ rec {
446446
};
447447

448448
genCheckProblems =
449-
config:
449+
config: defaultRequiresMaintainers:
450450
let
451451
# This is here so that it gets cached for a (checkProblems config) thunk
452452
inherit (genHandlerSwitch config)
@@ -468,11 +468,14 @@ rec {
468468
}
469469
) automaticProblems;
470470
in
471-
attrs: outputMeta:
471+
attrs: pos:
472+
let
473+
requiresMaintainers = attrs.meta.requiresMaintainers or (defaultRequiresMaintainers attrs pos);
474+
in
472475
if
473476
# Fast path for when there's no problem that needs to be handled
474477
all (
475-
problem: problem.condition attrs outputMeta -> problem.handler (getName attrs) == "ignore"
478+
problem: problem.condition attrs requiresMaintainers -> problem.handler (getName attrs) == "ignore"
476479
) automaticProblemsConfigCache
477480
&& (
478481
# No manual problems
@@ -488,7 +491,7 @@ rec {
488491
# Slow path, only here we actually figure out which problems we need to handle
489492
let
490493
pname = getName attrs;
491-
problems = attrs.meta.problems or { } // genAutomaticProblems config attrs outputMeta;
494+
problems = attrs.meta.problems or { } // genAutomaticProblems config attrs requiresMaintainers;
492495
problemsToHandle = filter (v: v.handler != "ignore") (
493496
mapAttrsToList (name: problem: rec {
494497
inherit name;

0 commit comments

Comments
 (0)