refactor: remove dead modules/lib/fs.nix file

This commit is contained in:
2024-10-01 03:55:29 +00:00
parent 61df81291b
commit 044bf8b783
2 changed files with 0 additions and 34 deletions

View File

@@ -3,7 +3,6 @@
let
sane-lib = rec {
feeds = import ./feeds.nix { inherit lib; };
fs = import ./fs.nix { inherit lib sane-lib; };
merge = import ./merge.nix { inherit lib sane-lib; };
path = import ./path.nix { inherit lib; };
types = import ./types.nix { inherit lib; };

View File

@@ -1,33 +0,0 @@
{ lib, sane-lib, ... }:
let
sane-path = sane-lib.path;
in rec {
# Type: derefSymlinkOrNull :: config.sane.fs.type -> str -> (str|null)
# the returned path is always absolute (even if the original symlink was relative),
# and in canonical form.
derefSymlinkOrNull = fs: logical: let
symlinkedPrefixes = lib.filter
(p: ((fs."${p}" or {}).symlink or null) != null)
(sane-path.walk "/" logical);
firstSymlink = builtins.head symlinkedPrefixes;
firstSymlinkDest = fs."${firstSymlink}".symlink.target;
firstSymlinkParent = sane-path.parent firstSymlink;
firstSymlinkDestAbs = if lib.hasPrefix "/" firstSymlinkDest then
firstSymlinkDest
else
sane-path.join [ firstSymlinkParent firstSymlinkDest ];
in
if symlinkedPrefixes != [] then
sane-path.realpath firstSymlinkDestAbs
else
null
;
derefSymlink = fs: logical:
if derefSymlinkOrNull fs logical != null then
derefSymlinkOrNull fs logical
else
logical
;
}