lib.filesystem: filesystem functions

lib.filesystem.pathType

Type: pathType :: Path -> String

The type of a path. The path needs to exist and be accessible. The result is either "directory" for a directory, "regular" for a regular file, "symlink" for a symlink, or "unknown" for anything else.

Example

lib.filesystem.pathType usage example

pathType /.
=> "directory"

pathType /some/file.nix
=> "regular"

Located at lib/filesystem.nix:33 in <nixpkgs>.

lib.filesystem.pathIsDirectory

Type: pathIsDirectory :: Path -> Bool

Whether a path exists and is a directory.

path

Function argument

Example

lib.filesystem.pathIsDirectory usage example

pathIsDirectory /.
=> true

pathIsDirectory /this/does/not/exist
=> false

pathIsDirectory /some/file.nix
=> false

Located at lib/filesystem.nix:65 in <nixpkgs>.

lib.filesystem.pathIsRegularFile

Type: pathIsRegularFile :: Path -> Bool

Whether a path exists and is a regular file, meaning not a symlink or any other special file type.

path

Function argument

Example

lib.filesystem.pathIsRegularFile usage example

pathIsRegularFile /.
=> false

pathIsRegularFile /this/does/not/exist
=> false

pathIsRegularFile /some/file.nix
=> true

Located at lib/filesystem.nix:84 in <nixpkgs>.

lib.filesystem.haskellPathsInDir

Type: Path -> Map String Path

A map of all haskell packages defined in the given path, identified by having a cabal file with the same name as the directory itself.

root

The directory within to search

Located at lib/filesystem.nix:94 in <nixpkgs>.

lib.filesystem.locateDominatingFile

Type: RegExp -> Path -> Nullable { path : Path; matches : [ MatchResults ]; }

Find the first directory containing a file matching 'pattern' upward from a given 'file'. Returns 'null' if no directories contain a file matching 'pattern'.

pattern

The pattern to search for

file

The file to start searching upward from

Located at lib/filesystem.nix:117 in <nixpkgs>.

lib.filesystem.listFilesRecursive

Type: Path -> [ Path ]

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

dir

The path to recursively list

Located at lib/filesystem.nix:145 in <nixpkgs>.