1
0
Fork 0
nixos-config/overlays/file-tree.nix
2021-06-06 17:32:44 +02:00

20 lines
502 B
Nix

final: prev:
let
inherit (prev) lib;
linkToPath = path: fileOrDir:
(
if lib.types.path.check fileOrDir then
[ "ln -sT ${fileOrDir} ${path}" ]
else
[ "mkdir -p ${path}" ] ++ lib.concatLists (
lib.mapAttrsToList
(dirName: content: linkToPath "${path}/${dirName}" content)
fileOrDir
)
);
in
{
setToDirectories = files: prev.runCommand "set-to-directories" { }
(lib.concatStringsSep "\n" (linkToPath "$out" files));
}