1
0
Fork 0

Factor out file-tree config

This commit is contained in:
Malte Brandy 2021-06-06 17:32:44 +02:00
parent e6d9c5cb33
commit 897cb95155
2 changed files with 20 additions and 13 deletions

View file

@ -100,19 +100,7 @@ in
LimitNOFILE = "1024000";
};
after = [ "network.target" ];
preStart =
let
linkToPath = path: fileOrDir:
(if types.path.check fileOrDir then
[ "ln -sT ${fileOrDir} ${path}" ]
else
[ "mkdir -p ${path}" ] ++ lib.concatLists (lib.mapAttrsToList
(dirName: content: linkToPath "${path}/${dirName}" content)
fileOrDir));
cfgDirContent = pkgs.runCommand "laminar-cfg-dir" { }
(lib.concatStringsSep "\n" (linkToPath "$out" cfg.cfgFiles));
in
"ln -sfT ${cfgDirContent} ${cfgDir}";
preStart = "ln -sfT ${pkgs.setToDirectories cfg.cfgFiles} ${cfgDir}";
};
services = {
nginx = {

19
overlays/file-tree.nix Normal file
View file

@ -0,0 +1,19 @@
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));
}