From 04fcbb45e1af2393c7ac372ed19d30ed5b1dd71f Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sun, 31 Aug 2025 11:24:31 +0200 Subject: [PATCH] ci/eval/attrpaths: refactor The following changes were made: - Using `lib.` instead of `builtins.` - Using `mapAttrsToList` instead of `mapAttrs` + `attrValues` - Joining two of the if conditions with the same return value - Using `traceIf` instead of `if` / `else` - Using `showAttrPath` instead of `concatStringsSep` --- ci/eval/attrpaths.nix | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/ci/eval/attrpaths.nix b/ci/eval/attrpaths.nix index 365f16da230e..c56ca5c7a56b 100644 --- a/ci/eval/attrpaths.nix +++ b/ci/eval/attrpaths.nix @@ -36,11 +36,13 @@ let # attrnames of derivations (!). We should probably restructure # the job tree so that this is not the case. # + # TODO: Use mapAttrsToListRecursiveCond when this PR lands: + # https://github.com/NixOS/nixpkgs/pull/395160 justAttrNames = path: value: let result = - if path == [ "AAAAAASomeThingsFailToEvaluate" ] then + if path == [ "AAAAAASomeThingsFailToEvaluate" ] || !(lib.isAttrs value) then [ ] else if lib.isDerivation value @@ -49,27 +51,22 @@ let !(value.__recurseIntoDerivationForReleaseJobs or false) then [ path ] - - else if !(lib.isAttrs value) then - [ ] else lib.pipe value [ - (builtins.mapAttrs ( + (lib.mapAttrsToList ( name: value: - builtins.addErrorContext "while evaluating package set attribute path '${ + lib.addErrorContext "while evaluating package set attribute path '${ lib.showAttrPath (path ++ [ name ]) }'" (justAttrNames (path ++ [ name ]) value) )) - builtins.attrValues - builtins.concatLists + lib.concatLists ]; in - if !trace then result else lib.trace "** ${lib.concatStringsSep "." path}" result; + lib.traceIf trace "** ${lib.showAttrPath path}" result; outpaths = import ./outpaths.nix { - inherit checkMeta; + inherit checkMeta path; attrNamesOnly = true; - inherit path; }; paths = [ @@ -91,7 +88,7 @@ let ] ++ justAttrNames [ ] outpaths; - names = map (path: (lib.concatStringsSep "." path)) paths; + names = map lib.showAttrPath paths; in {