query
On this page

listFilesRecursive

lib.filesystem.listFilesRecursive

Docs pulled from | This Revision | 4 days ago


Given a directory, return a flattened list of all files within it recursively.

Inputs

dir

The path to recursively list

Type

Path -> [ Path ]

Noogle detected

Implementation

The following is the current implementation of this function.

listFilesRecursive =
    let
      # We only flatten at the very end, as flatten is recursive.
      internalFunc =
        dir:
        (lib.mapAttrsToList (
          name: type: if type == "directory" then internalFunc (dir + "/${name}") else dir + "/${name}"
        ) (builtins.readDir dir));
    in
    dir: lib.flatten (internalFunc dir);