mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
lib.sources.pathType and co.: Move to lib.filesystem
These functions only work with the filesystem, they don't import anything as sources
This commit is contained in:
parent
a8e4f58d90
commit
c701a4dd29
3 changed files with 47 additions and 21 deletions
|
@ -2,12 +2,38 @@
|
|||
{ lib }:
|
||||
|
||||
let
|
||||
inherit (builtins)
|
||||
getAttr
|
||||
readDir
|
||||
pathExists
|
||||
;
|
||||
|
||||
inherit (lib.strings)
|
||||
hasPrefix
|
||||
;
|
||||
|
||||
inherit (lib.filesystem)
|
||||
pathType
|
||||
;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
/*
|
||||
Returns the type of a path: regular (for file), symlink, or directory.
|
||||
*/
|
||||
pathType = path: getAttr (baseNameOf path) (readDir (dirOf path));
|
||||
|
||||
/*
|
||||
Returns true if the path exists and is a directory, false otherwise.
|
||||
*/
|
||||
pathIsDirectory = path: if pathExists path then (pathType path) == "directory" else false;
|
||||
|
||||
/*
|
||||
Returns true if the path exists and is a regular file, false otherwise.
|
||||
*/
|
||||
pathIsRegularFile = path: if pathExists path then (pathType path) == "regular" else false;
|
||||
|
||||
/*
|
||||
A map of all haskell packages defined in the given path,
|
||||
identified by having a cabal file with the same name as the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue