lib.filesystem.listFilesRecursive: only flatten once

This commit is contained in:
Eman Resu
2025-10-07 20:50:13 -04:00
parent 3b837fa81a
commit ca59048a42

View File

@@ -239,16 +239,15 @@ in
``` ```
*/ */
listFilesRecursive = listFilesRecursive =
let
# We only flatten at the very end, as flatten is recursive.
internalFunc =
dir: dir:
lib.flatten ( (lib.mapAttrsToList (
lib.mapAttrsToList ( name: type: if type == "directory" then internalFunc (dir + "/${name}") else dir + "/${name}"
name: type: ) (builtins.readDir dir));
if type == "directory" then in
lib.filesystem.listFilesRecursive (dir + "/${name}") dir: lib.flatten (internalFunc dir);
else
dir + "/${name}"
) (builtins.readDir dir)
);
/** /**
Transform a directory tree containing package files suitable for Transform a directory tree containing package files suitable for