diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-04-05 16:10:09 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-04-05 17:18:10 +0200 |
commit | c701a4dd299aaa82589e4e4d4ce49ae330729a25 (patch) | |
tree | 79187c5ce01e9ab56881d38b828d5ac6fd27dfa8 /lib/sources.nix | |
parent | a8e4f58d903295920c5a3cdb3d4882d0675b0480 (diff) | |
download | nixpkgs-c701a4dd299aaa82589e4e4d4ce49ae330729a25.tar nixpkgs-c701a4dd299aaa82589e4e4d4ce49ae330729a25.tar.gz nixpkgs-c701a4dd299aaa82589e4e4d4ce49ae330729a25.tar.bz2 nixpkgs-c701a4dd299aaa82589e4e4d4ce49ae330729a25.tar.lz nixpkgs-c701a4dd299aaa82589e4e4d4ce49ae330729a25.tar.xz nixpkgs-c701a4dd299aaa82589e4e4d4ce49ae330729a25.tar.zst nixpkgs-c701a4dd299aaa82589e4e4d4ce49ae330729a25.zip |
lib.sources.pathType and co.: Move to lib.filesystem
These functions only work with the filesystem, they don't import anything as sources
Diffstat (limited to 'lib/sources.nix')
-rw-r--r-- | lib/sources.nix | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/sources.nix b/lib/sources.nix index 3ad7dc63355..d990777c6fc 100644 --- a/lib/sources.nix +++ b/lib/sources.nix @@ -18,21 +18,11 @@ let pathExists readFile ; - - /* - 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; + inherit (lib.filesystem) + pathType + pathIsDirectory + pathIsRegularFile + ; /* A basic filter for `cleanSourceWith` that removes @@ -271,11 +261,20 @@ let }; in { - inherit - pathType - pathIsDirectory - pathIsRegularFile + pathType = lib.warnIf (lib.isInOldestRelease 2305) + "lib.sources.pathType has been moved to lib.filesystem.pathType." + lib.filesystem.pathType; + + pathIsDirectory = lib.warnIf (lib.isInOldestRelease 2305) + "lib.sources.pathIsDirectory has been moved to lib.filesystem.pathIsDirectory." + lib.filesystem.pathIsDirectory; + + pathIsRegularFile = lib.warnIf (lib.isInOldestRelease 2305) + "lib.sources.pathIsRegularFile has been moved to lib.filesystem.pathIsRegularFile." + lib.filesystem.pathIsRegularFile; + + inherit pathIsGitRepo commitIdFromGitRepo |