repo-clone/service.nix

39 lines
967 B
Nix
Raw Normal View History

2024-08-01 08:48:41 +00:00
{ config, service, pkgs }:
let
inherit (pkgs)
writeShellScriptBin;
in
{
Unit = {
Description = "${service} service";
X-Restart-Triggers = [ "${config.repo-clone.pkg}" ];
};
Service = {
Type = "exec";
ExecStart =
let
execName = service;
script = writeShellScriptBin execName ''
2024-08-01 09:10:43 +00:00
while IFS="" read -r p || [ -n "$p" ]
do
2024-08-01 09:37:36 +00:00
args=($p) # [0]: repo-url [1]: target-path
repo=''${args[0]}
target=''${args[1]}
if [ -d "$target" ]; then
if "''$(${pkgs.findutils}/bin/find "''$target" -maxdepth 0 -empty)"; then
echo "~ Found Files at ''$target ~"
else
echo "~ No Files in ''$target ~"
fi
fi
2024-08-01 09:10:43 +00:00
done < "${config.repo-clone.pkg}"
2024-08-01 08:48:41 +00:00
'';
in
"${script}/bin/${execName}";
RemainAfterExit = "yes";
};
Install.WantedBy = [ "multi-user.target" ];
}