summary refs log tree commit diff
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-04-05 16:13:03 +0200
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-05-22 14:13:57 +0200
commit5346636c20ff57410b25a6a8897d4e95f75e040c (patch)
tree45f9626c807f18034a21025abc9f75b6a7af5ebf
parenta1dedc908d1d9f7e2b9490dc7b3b3020e8fe7d0b (diff)
downloadnixpkgs-5346636c20ff57410b25a6a8897d4e95f75e040c.tar
nixpkgs-5346636c20ff57410b25a6a8897d4e95f75e040c.tar.gz
nixpkgs-5346636c20ff57410b25a6a8897d4e95f75e040c.tar.bz2
nixpkgs-5346636c20ff57410b25a6a8897d4e95f75e040c.tar.lz
nixpkgs-5346636c20ff57410b25a6a8897d4e95f75e040c.tar.xz
nixpkgs-5346636c20ff57410b25a6a8897d4e95f75e040c.tar.zst
nixpkgs-5346636c20ff57410b25a6a8897d4e95f75e040c.zip
lib.filesystem: Minor refactor
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
-rw-r--r--lib/filesystem.nix10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/filesystem.nix b/lib/filesystem.nix
index 2d8a62639ec..f604eb90434 100644
--- a/lib/filesystem.nix
+++ b/lib/filesystem.nix
@@ -3,7 +3,6 @@
 
 let
   inherit (builtins)
-    getAttr
     readDir
     pathExists
     ;
@@ -22,17 +21,20 @@ in
   /*
     Returns the type of a path: regular (for file), symlink, or directory.
   */
-  pathType = path: getAttr (baseNameOf path) (readDir (dirOf path));
+  pathType = path:
+    (readDir (dirOf path)).${baseNameOf path};
 
   /*
     Returns true if the path exists and is a directory, false otherwise.
   */
-  pathIsDirectory = path: if pathExists path then (pathType path) == "directory" else false;
+  pathIsDirectory = path:
+    pathExists path && pathType path == "directory";
 
   /*
     Returns true if the path exists and is a regular file, false otherwise.
   */
-  pathIsRegularFile = path: if pathExists path then (pathType path) == "regular" else false;
+  pathIsRegularFile = path:
+    pathExists path && pathType path == "regular";
 
   /*
     A map of all haskell packages defined in the given path,