summary refs log tree commit diff
path: root/lib/filesystem.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/filesystem.nix')
-rw-r--r--lib/filesystem.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/filesystem.nix b/lib/filesystem.nix
index 13f4ebb26402f..db120a48c64be 100644
--- a/lib/filesystem.nix
+++ b/lib/filesystem.nix
@@ -22,10 +22,14 @@ in
     Returns the type of a path: regular (for file), symlink, or directory.
   */
   pathType = path:
+    if ! pathExists path
+    # Fail irrecoverably to mimic the historic behavior of this function and
+    # the new builtins.readFileType
+    then abort "lib.filesystem.pathType: Path ${toString path} does not exist."
     # The filesystem root is the only path where `dirOf / == /` and
     # `baseNameOf /` is not valid. We can detect this and directly return
     # "directory", since we know the filesystem root can't be anything else.
-    if dirOf path == path
+    else if dirOf path == path
     then "directory"
     else (readDir (dirOf path)).${baseNameOf path};