From 261b8489a08855971e056b3a220db7d8e4cf6883 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Thu, 21 May 2026 16:40:17 -0400 Subject: [PATCH] lib.lists.foldl': avoid builtins lookups --- lib/lists.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/lists.nix b/lib/lists.nix index abd9aceed0e3..7fb9d21a1f2e 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -6,8 +6,9 @@ let inherit (lib.strings) toInt; inherit (lib.trivial) compare - min id + min + seq warn ; inherit (lib.attrsets) mapAttrs attrNames attrValues; @@ -276,11 +277,14 @@ rec { ::: */ foldl' = + let + inherit (builtins) foldl'; + in op: acc: # The builtin `foldl'` is a bit lazier than one might expect. # See https://github.com/NixOS/nix/pull/7158. # In particular, the initial accumulator value is not forced before the first iteration starts. - builtins.seq acc (builtins.foldl' op acc); + seq acc (foldl' op acc); /** Map with index starting from 0