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:50:57 +00:00
|
|
|
# Include hidden files when globbing later
|
|
|
|
shopt -s nullglob dotglob
|
|
|
|
|
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]}
|
|
|
|
|
2024-08-01 09:50:57 +00:00
|
|
|
if [ -d "''$target" ]; then
|
2024-08-01 09:37:36 +00:00
|
|
|
if "''$(${pkgs.findutils}/bin/find "''$target" -maxdepth 0 -empty)"; then
|
|
|
|
echo "~ Found Files at ''$target ~"
|
2024-08-01 09:50:57 +00:00
|
|
|
else
|
|
|
|
echo "~ No Files in ''$target ~"
|
2024-08-01 09:37:36 +00:00
|
|
|
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" ];
|
|
|
|
}
|