mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
rclone: add rclone-sidecar-wrapper derivation
Bash helper that waits up to 5 minutes for rclone.conf to exist before exec'ing its arguments. Will be wired into the launchd sidecar agents in a follow-up commit.
This commit is contained in:
committed by
Austin Horstman
parent
f99cd3d4f4
commit
2b6c692c95
@@ -163,6 +163,32 @@ let
|
||||
) (lib.attrsToList cfg.remotes)
|
||||
);
|
||||
|
||||
# Darwin-only: wraps each rclone mount/serve invocation, polling for
|
||||
# rclone.conf before exec'ing. Substitutes for systemd's
|
||||
# `After=rclone-config.service` ordering. Has no consumers on Linux.
|
||||
rcloneSidecarWrapper = pkgs.writeShellApplication {
|
||||
name = "rclone-sidecar-wrapper";
|
||||
|
||||
runtimeInputs = [
|
||||
pkgs.coreutils
|
||||
];
|
||||
|
||||
text = ''
|
||||
configPath="${config.xdg.configHome}/rclone/rclone.conf"
|
||||
deadline=$(( $(date +%s) + 300 ))
|
||||
|
||||
while [ ! -f "$configPath" ]; do
|
||||
if [ "$(date +%s)" -ge "$deadline" ]; then
|
||||
echo "Timeout waiting for $configPath" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
exec "$@"
|
||||
'';
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.maintainers; [ jess ];
|
||||
|
||||
Reference in New Issue
Block a user