modules/programs: fix symlink following
This commit is contained in:
@@ -15,11 +15,12 @@ in rec {
|
|||||||
(p: ((fs."${p}" or {}).symlink or null) != null)
|
(p: ((fs."${p}" or {}).symlink or null) != null)
|
||||||
(sane-path.walk "/" logical);
|
(sane-path.walk "/" logical);
|
||||||
firstSymlink = builtins.head symlinkedPrefixes;
|
firstSymlink = builtins.head symlinkedPrefixes;
|
||||||
firstSymlinkDest = "${firstSymlink}".symlink.target;
|
firstSymlinkDest = fs."${firstSymlink}".symlink.target;
|
||||||
firstSymlinkParent = sane-path.parent firstSymlink;
|
firstSymlinkParent = sane-path.parent firstSymlink;
|
||||||
firstSymlinkDestAbs = if lib.hasPrefix "/" firstSymlinkDest then
|
firstSymlinkDestAbs = if lib.hasPrefix "/" firstSymlinkDest then
|
||||||
firstSymlinkDest
|
firstSymlinkDest
|
||||||
else
|
else
|
||||||
|
# TODO: path canonicalization (for i.e. relative symlinks)
|
||||||
sane-path.join [ firstSymlinkParent firstSymlinkDest ];
|
sane-path.join [ firstSymlinkParent firstSymlinkDest ];
|
||||||
in
|
in
|
||||||
if symlinkedPrefixes != [] then
|
if symlinkedPrefixes != [] then
|
||||||
|
@@ -47,7 +47,7 @@ let
|
|||||||
removeStorePaths = paths: lib.filter (p: !(lib.hasPrefix "/nix/store" p)) paths;
|
removeStorePaths = paths: lib.filter (p: !(lib.hasPrefix "/nix/store" p)) paths;
|
||||||
|
|
||||||
# derefSymlinks: [ str ] -> [ str ]: for each path which is a symlink (or a child of a symlink'd dir), dereference one layer of symlink. else, drop it from the list.
|
# derefSymlinks: [ str ] -> [ str ]: for each path which is a symlink (or a child of a symlink'd dir), dereference one layer of symlink. else, drop it from the list.
|
||||||
derefSymlinks' = paths: builtins.map (fs-lib.derefSymlinkOrNull fs) paths;
|
derefSymlinks' = paths: builtins.map (fs-lib.derefSymlinkOrNull config.sane.fs) paths;
|
||||||
derefSymlinks = paths: lib.filter (p: p != null) (derefSymlinks' paths);
|
derefSymlinks = paths: lib.filter (p: p != null) (derefSymlinks' paths);
|
||||||
# expandSymlinksOnce: [ str ] -> [ str ], returning all the original paths plus dereferencing any symlinks and adding their targets to this list.
|
# expandSymlinksOnce: [ str ] -> [ str ], returning all the original paths plus dereferencing any symlinks and adding their targets to this list.
|
||||||
expandSymlinksOnce = paths: lib.unique (paths ++ removeStorePaths (derefSymlinks paths));
|
expandSymlinksOnce = paths: lib.unique (paths ++ removeStorePaths (derefSymlinks paths));
|
||||||
|
Reference in New Issue
Block a user