Skip to content

Commit 677425c

Browse files
committed
check-meta: Avoid expensive evaluation of output meta
Thanks for the pointer @llakala!
1 parent c8c80c8 commit 677425c

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

pkgs/stdenv/generic/check-meta.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ let
5353
problemsType
5454
genCheckProblems
5555
;
56-
checkProblems = genCheckProblems config;
56+
checkProblems = genCheckProblems config defaultRequiresMaintainers;
5757

5858
# If we're in hydra, we can dispense with the more verbose error
5959
# messages and make problems easier to spot.
@@ -713,10 +713,10 @@ let
713713
builtins.seq (foldl' giveWarning null warnings) withError;
714714

715715
assertValidity =
716-
{ meta, attrs }:
716+
{ meta, attrs, pos ? null }:
717717
let
718718
invalid = checkValidity attrs;
719-
problems = checkProblems attrs meta;
719+
problems = checkProblems attrs pos;
720720
in
721721
if isNull invalid then
722722
if isNull problems then

pkgs/stdenv/generic/make-derivation.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ let
956956
++ attrs.propagatedNativeBuildInputs or [ ]
957957
++ attrs.propagatedBuildInputs or [ ];
958958
};
959-
validity = checkMeta.assertValidity { inherit meta attrs; };
959+
validity = checkMeta.assertValidity { inherit meta attrs pos; };
960960

961961
checkedEnv =
962962
let

pkgs/stdenv/generic/problems.nix

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ rec {
9494
{
9595
kindName = "maintainerless";
9696
condition =
97-
config: attrs: outputMeta:
98-
outputMeta.requiresMaintainers
97+
config: attrs: requiresMaintainers:
98+
requiresMaintainers
9999
&& (attrs.meta.maintainers or [ ] == [ ])
100100
&& (attrs.meta.teams or [ ] == [ ])
101101
&& (attrs.meta.hasNoMaintainersButDependents or false == false);
@@ -117,16 +117,16 @@ rec {
117117
else
118118
x: false;
119119
in
120-
attrs: outputMeta: attrs.meta.broken or false && !allowBroken && !allowBrokenPredicate attrs;
120+
attrs: requiresMaintainers: attrs.meta.broken or false && !allowBroken && !allowBrokenPredicate attrs;
121121
value.message = "This package is broken.";
122122
}
123123
];
124124

125125
genAutomaticProblems =
126-
config: attrs: outputMeta:
126+
config: attrs: requiresMaintainers:
127127
listToAttrs (
128128
map (problem: lib.nameValuePair problem.kindName problem.value) (
129-
filter (problem: problem.condition config attrs outputMeta) automaticProblems
129+
filter (problem: problem.condition config attrs requiresMaintainers) automaticProblems
130130
)
131131
);
132132

@@ -425,6 +425,7 @@ rec {
425425

426426
genCheckProblems =
427427
config:
428+
defaultRequiresMaintainers:
428429
let
429430
# This is here so that it gets cached for a (checkProblems config) thunk
430431
inherit (genHandlerSwitch config)
@@ -435,17 +436,18 @@ rec {
435436
problem: problem // { condition = problem.condition config; }
436437
) automaticProblems;
437438
in
438-
attrs: outputMeta:
439+
attrs: pos:
439440
let
440441
pname = getName attrs;
441442
manualProblems = attrs.meta.problems or { };
443+
requiresMaintainers = attrs.meta.requiresMaintainers or (defaultRequiresMaintainers attrs pos);
442444
in
443445
if
444446
# Fast path for when there's no problem that needs to be handled
445447
# No automatic problems that needs handling
446448
all (
447449
problem:
448-
problem.condition attrs outputMeta
450+
problem.condition attrs requiresMaintainers
449451
-> handlerForProblem pname problem.kindName problem.kindName == "ignore"
450452
) automaticProblemsConfigCache
451453
&& (
@@ -461,7 +463,7 @@ rec {
461463
else
462464
# Slow path, only here we actually figure out which problems we need to handle
463465
let
464-
problems = attrs.meta.problems or { } // genAutomaticProblems config attrs outputMeta;
466+
problems = attrs.meta.problems or { } // genAutomaticProblems config attrs requiresMaintainers;
465467
problemsToHandle = filter (v: v.handler != "ignore") (
466468
mapAttrsToList (name: problem: rec {
467469
inherit name;

0 commit comments

Comments
 (0)