diff --git a/pkgs/stdenv/generic/problems.nix b/pkgs/stdenv/generic/problems.nix index 348786ab5242..0d0260ef6afc 100644 --- a/pkgs/stdenv/generic/problems.nix +++ b/pkgs/stdenv/generic/problems.nix @@ -434,10 +434,10 @@ rec { inherit switch definedConstraints; handlerForProblem = if isString switch then - pname: name: kind: + kind: name: pname: switch else - pname: name: kind: + kind: name: pname: let switch' = switch.kindSpecific.${kind} or switch.kindFallback; in @@ -466,12 +466,14 @@ rec { configuredProblems = definedConstraints.kinds ++ definedConstraints.names; # Filter out any problems that are always ignored in config.problems. - # Makes sure that automatic problems can cache with just config applied + # Makes sure to cache the condition by appliny config, and the handler + # by applying the problem's kind and name automaticProblemsConfigCache = concatMap ( problem: - optionals (elem problem.kindName configuredProblems) [ - (problem // { condition = problem.condition config; }) - ] + optional (elem problem.kindName configuredProblems) { + condition = problem.condition config; + handler = handlerForProblem problem.kindName problem.kindName; + } ) automaticProblems; in attrs: @@ -480,16 +482,14 @@ rec { in if # Fast path for when there's no problem that needs to be handled - # No automatic problems that needs handling all ( - problem: - problem.condition attrs -> handlerForProblem pname problem.kindName problem.kindName == "ignore" + problem: problem.condition attrs -> problem.handler pname == "ignore" ) automaticProblemsConfigCache && ( # No manual problems !attrs ? meta.problems # Or all manual problems are ignored - || all (name: handlerForProblem pname name (attrs.meta.problems.${name}.kind or name) == "ignore") ( + || all (name: handlerForProblem (attrs.meta.problems.${name}.kind or name) name pname == "ignore") ( attrNames attrs.meta.problems ) ) @@ -504,7 +504,7 @@ rec { inherit name; # Kind falls back to the name kind = problem.kind or name; - handler = handlerForProblem pname name kind; + handler = handlerForProblem kind name pname; inherit problem; }) problems ); diff --git a/pkgs/test/problems/unit.nix b/pkgs/test/problems/unit.nix index 4a8076a84a7f..aef201508e63 100644 --- a/pkgs/test/problems/unit.nix +++ b/pkgs/test/problems/unit.nix @@ -10,7 +10,7 @@ let genHandlerTest = let slowReference = - config: package: name: kind: + config: kind: name: package: # Try to find an explicit handler (config.problems.handlers.${package} or { }).${name} # Fall back, iterating through the matchers @@ -36,7 +36,7 @@ let map ( name: - map (kind: f package name kind) [ + map (kind: f kind name package) [ "k1" "k2" "k3"