From d9ce06790d3d58ee8139017658774e98f359e8c3 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Fri, 1 Aug 2025 15:49:53 +0200 Subject: [PATCH 1/2] stdenv: Remove extra merge operator in meta This operator merges two attrsets without any conditions, and leads to more operations and allocations. --- pkgs/stdenv/generic/check-meta.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index b1433dac99b66..f5f229290dec9 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -622,8 +622,7 @@ let # if you add a new maintainer or team attribute please ensure that this expectation is still met. maintainers = attrs.meta.maintainers or [ ] ++ concatMap (team: team.members or [ ]) attrs.meta.teams or [ ]; - } - // { + # Expose the result of the checks for everyone to see. unfree = hasUnfreeLicense attrs; broken = isMarkedBroken attrs; From 60d2cc07ad97e33578d9cd7f64c9df1ceae058ce Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Fri, 1 Aug 2025 17:56:36 +0200 Subject: [PATCH 2/2] stdenv: add all positions to meta without merges Remove usage of filterAttrs and two more attrset merges. Saves more time and memory. --- pkgs/stdenv/generic/check-meta.nix | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index f5f229290dec9..213da04d76956 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -26,7 +26,6 @@ let isAttrs isString mapAttrs - filterAttrs ; inherit (lib.lists) @@ -576,6 +575,8 @@ let let outputs = attrs.outputs or [ "out" ]; hasOutput = out: builtins.elem out outputs; + maintainersPosition = builtins.unsafeGetAttrPos "maintainers" (attrs.meta or { }); + teamsPosition = builtins.unsafeGetAttrPos "teams" (attrs.meta or { }); in { # `name` derivation attribute includes cross-compilation cruft, @@ -604,19 +605,17 @@ let ) ] ++ optional (hasOutput "man") "man"; - } - // (filterAttrs (_: v: v != null) { + # CI scripts look at these to determine pings. Note that we should filter nulls out of this, # or nix-env complains: https://github.com/NixOS/nix/blob/2.18.8/src/nix-env/nix-env.cc#L963 - maintainersPosition = builtins.unsafeGetAttrPos "maintainers" (attrs.meta or { }); - teamsPosition = builtins.unsafeGetAttrPos "teams" (attrs.meta or { }); - }) - // attrs.meta or { } - # Fill `meta.position` to identify the source location of the package. - // optionalAttrs (pos != null) { - position = pos.file + ":" + toString pos.line; + ${if maintainersPosition == null then null else "maintainersPosition"} = maintainersPosition; + ${if teamsPosition == null then null else "teamsPosition"} = teamsPosition; } + // attrs.meta or { } // { + # Fill `meta.position` to identify the source location of the package. + ${if pos == null then null else "position"} = pos.file + ":" + toString pos.line; + # Maintainers should be inclusive of teams. # Note that there may be external consumers of this API (repology, for instance) - # if you add a new maintainer or team attribute please ensure that this expectation is still met.