From bb3308e01eb581dac83f0370c4a0e5ab564799e2 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Thu, 21 May 2026 16:53:18 -0400 Subject: [PATCH] lib.lists.takeEnd: rewrite to not call `sublist` --- lib/lists.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/lists.nix b/lib/lists.nix index f48cf19ea3f2..0892406f6815 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -1547,7 +1547,13 @@ rec { ::: */ - takeEnd = n: xs: drop (max 0 (length xs - n)) xs; + takeEnd = + count: list: + let + len = length list; + start = if count > len then 0 else len - count; + in + genList (i: elemAt list (start + i)) (if start > len then 0 else len - start); /** Remove the first (at most) N elements of a list.