-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
featureFeature request or proposalFeature request or proposallanguageThe Nix expression language; parser, interpreter, primops, evaluation, etcThe Nix expression language; parser, interpreter, primops, evaluation, etcstale
Description
I'm proposing to add a new builtins.pathType that returns the node type, similar to the values returned by builtins.readDir.
Motivation
Avoid having to read a directory when all you need is a single path's node type.
Spec
Like builtins.pathExists, its argument is a path or string that may or may not exist on the filesystem.
Given argument p return value is
nullwhen the pathpdoes not point to an existing filesystem node- a value equal to
(builtins.readDir (dirOf p))."$(baseNameOf p)", such as "directory", "regular", "symlink"
Advantages
- Performance: no need to read the entire directory (may be big, like
/nix/store) - Less strict:
readDir (dirOf p)may not be allowed by dir permissions - Decreases the file watch scope for tools like
lorri
infinisil
Metadata
Metadata
Assignees
Labels
featureFeature request or proposalFeature request or proposallanguageThe Nix expression language; parser, interpreter, primops, evaluation, etcThe Nix expression language; parser, interpreter, primops, evaluation, etcstale