From 5ae9907466e0337ec5958642cf6f7263ce8f1ec2 Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Fri, 28 Aug 2026 13:05:10 +0200 Subject: [PATCH 1/4] stdenv/problems: pre-apply config to genAutomaticProblems This makes it a bit cheaper to call the completeMetaProblems function as the automatic problems are only generated once (per `config` instance). --- pkgs/stdenv/generic/problems.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/generic/problems.nix b/pkgs/stdenv/generic/problems.nix index 887242e53684..ae2ef4a59e22 100644 --- a/pkgs/stdenv/generic/problems.nix +++ b/pkgs/stdenv/generic/problems.nix @@ -525,9 +525,13 @@ rec { processProblems pname problemsToHandle; completeMetaProblems = - config: attrs: + config: + let + automaticProblems = genAutomaticProblems config; + in + attrs: mapAttrs (name: problem: { kind = name; } // problem) ( - (attrs.meta.problems or { }) // genAutomaticProblems config attrs + (attrs.meta.problems or { }) // automaticProblems attrs ); processProblems = From e647142042648be3ed16c3378a330340e01f0f75 Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Fri, 28 Aug 2026 13:12:23 +0200 Subject: [PATCH 2/4] stdenv/check-meta: cache the problem generators per config instance This is similar to how we use the genCheckProblems function for the generic problem generation. Accessing multiple `meta.problems` fields should become slightly cheaper now. --- pkgs/stdenv/generic/check-meta.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 08e2c7a37a09..2834e6c56a4a 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -450,6 +450,9 @@ let # meta = checkMeta.commonMeta hostPlatform { inherit validity attrs pos references; }; # validity = checkMeta.assertValidity hostPlatform { inherit meta attrs; }; commonMeta = + let + completeMetaProblems' = completeMetaProblems config; + in hostPlatform: let hasUnsupportedPlatform' = hasUnsupportedPlatform hostPlatform; @@ -595,7 +598,7 @@ let unsupported = hasUnsupportedPlatform' attrs; insecure = isMarkedInsecure attrs; - problems = completeMetaProblems config attrs; + problems = completeMetaProblems' attrs; available = validity.valid != "no" From 45db34b3082b519ed62a978a8cc26cca38ed283a Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Fri, 28 Aug 2026 13:14:43 +0200 Subject: [PATCH 3/4] stdenv/check-meta: set meta.broken also based on the problem code This pulls in the brokenness information from the meta.problems fields. This decouples the both implementation from each other (slightly). Whatever the metric for brokenness in meta.problems is now carries over to old meta.broken attribute. Right now there is no difference in the value of meta.broken since the both implementations are almost identical. As future work we could now drop the logic from `check-meta.nix` and rely solely on the problems code to do the brokenness detection without abandoning `meta.broken` as value to query. --- pkgs/stdenv/generic/check-meta.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 2834e6c56a4a..24e08ca8295a 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -18,6 +18,7 @@ let isFunction isString length + mapAttrsToList mutuallyExclusive optional optionalString @@ -25,6 +26,7 @@ let unsafeGetAttrPos warn all + groupBy ; inherit (lib.lists) @@ -468,6 +470,17 @@ let hasOutput = out: elem out outputs; maintainersPosition = unsafeGetAttrPos "maintainers" (attrs.meta or { }); teamsPosition = unsafeGetAttrPos "teams" (attrs.meta or { }); + + problems = completeMetaProblems' attrs; + problemsGroupedByKind = groupBy (p: p.name) ( + mapAttrsToList (name: problem: { + inherit name; + inherit problem; + }) problems + ); + + problemsByKind = kind: problemsGroupedByKind.${kind} or [ ]; + hasProblemKind = kind: (problemsByKind kind) != [ ]; in { # `name` derivation attribute includes cross-compilation cruft, @@ -594,11 +607,11 @@ let # Expose the result of the checks for everyone to see. unfree = hasUnfreeLicense attrs; - broken = isMarkedBroken attrs; + broken = isMarkedBroken attrs || hasProblemKind "broken"; unsupported = hasUnsupportedPlatform' attrs; insecure = isMarkedInsecure attrs; - problems = completeMetaProblems' attrs; + inherit problems; available = validity.valid != "no" From 2ff9e8428026f929f693e6b78046c8b835f20cb4 Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Fri, 4 Sep 2026 12:57:10 +0200 Subject: [PATCH 4/4] stdenv/check-meta: drop isMarkedBroken in favour of auto problems For some time we've had the meta.problems automatic problems detect brokenness of a package (same logic; looking at meta.broken) but also kept the "legacy" code to propagate the information into the final meta attrset. Since we already have the problems information as part of the commonMeta implementation we can make use of that to propagate the field. We now only have one implementation for the broken attribute. Yay. --- pkgs/stdenv/generic/check-meta.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 24e08ca8295a..724e8b8ccac4 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -136,8 +136,6 @@ let hasUnfreeLicense = attrs: attrs ? meta.license && isUnfree attrs.meta.license; - isMarkedBroken = attrs: attrs.meta.broken or false; - # Logical inversion of meta.availableOn for hostPlatform hasUnsupportedPlatform = if allowUnsupportedSystem then @@ -607,7 +605,7 @@ let # Expose the result of the checks for everyone to see. unfree = hasUnfreeLicense attrs; - broken = isMarkedBroken attrs || hasProblemKind "broken"; + broken = hasProblemKind "broken"; unsupported = hasUnsupportedPlatform' attrs; insecure = isMarkedInsecure attrs;