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

20 lines
502 B
Nix
Raw Normal View History

2021-06-06 15:32:44 +00:00
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));
}