From f366cf3e49a6a3ce9afa0f3a6b72a488437c91a4 Mon Sep 17 00:00:00 2001 From: Bo Jeanes Date: Sun, 11 Aug 2024 19:18:33 +1000 Subject: [PATCH] Set up regular task to clear ~/Downloads of older files --- flake.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/flake.nix b/flake.nix index 0d97f06..8b39b2f 100644 --- a/flake.nix +++ b/flake.nix @@ -170,6 +170,25 @@ ''; }; + launchd.user.agents.gc-downloads = + let + # shell = "${pkgs.bash}/bin/bash"; + find = "${pkgs.findutils}/bin/find"; + downloads = "/Users/${myUsername}/Downloads"; + in + { + serviceConfig = { + ProcessType = "Background"; + RunAtLoad = true; + StartInterval = 6 * 60 * 60; # every 6 hours + }; + + script = '' + ${find} ${downloads} -type f -mtime +30 -print -delete + ${find} ${downloads} -type d -not -wholename "${downloads}" -empty -print -delete + ''; + }; + homebrew.enable = true; homebrew.taps = [ "exoscale/tap"