1
0
Fork 0
nixos-config/overlays/file-tree.nix

19 lines
463 B
Nix
Raw Normal View History

2022-03-08 04:53:07 +00:00
_: prev: let
2021-06-06 15:32:44 +00:00
inherit (prev) lib;
2022-03-08 01:42:46 +00:00
linkToPath = path: fileOrDir: (
2022-03-08 04:53:07 +00:00
if prev.lib.types.path.check fileOrDir
2022-03-08 01:42:46 +00:00
then ["ln -sT ${fileOrDir} ${path}"]
else
["mkdir -p ${path}"]
++ lib.concatLists (
lib.mapAttrsToList
2022-03-08 02:19:09 +00:00
(dirName: linkToPath "${path}/${dirName}")
2022-03-08 01:42:46 +00:00
fileOrDir
)
);
in {
setToDirectories = files:
prev.runCommand "set-to-directories" {}
2021-06-06 15:32:44 +00:00
(lib.concatStringsSep "\n" (linkToPath "$out" files));
}