| 1 | { |
| 2 | # Prune the Rosetta JIT bytecode cache |
| 3 | # Probably purges more than that, see |
| 4 | # https://github.com/nix-darwin/nix-darwin/pull/1165#issuecomment-2477157627 |
| 5 | launchd.daemons.rosetta2-gc = { |
| 6 | script = '' |
| 7 | date |
| 8 | exec /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -P -minsize 0 /System/Volumes/Data |
| 9 | ''; |
| 10 | serviceConfig.StartInterval = 3600 * 2; |
| 11 | serviceConfig.RunAtLoad = true; |
| 12 | serviceConfig.StandardErrorPath = "/var/log/rosetta2-gc.log"; |
| 13 | serviceConfig.StandardOutPath = "/var/log/rosetta2-gc.log"; |
| 14 | }; |
| 15 | |
| 16 | # MacOS stores extensive logs in /var/db/uuidtext, which cause high disk usage |
| 17 | # Manually: find /var/db/uuidtext -type f -mtime +7 -delete |
| 18 | launchd.daemons.log-erase = { |
| 19 | script = '' |
| 20 | date |
| 21 | log erase --all |
| 22 | ''; |
| 23 | serviceConfig.StartInterval = 3600 * 24; |
| 24 | serviceConfig.StandardErrorPath = "/var/log/uuidtext-gc.log"; |
| 25 | serviceConfig.StandardOutPath = "/var/log/uuidtext-gc.log"; |
| 26 | }; |
| 27 | |
| 28 | # Regularly kill fseventsd to reclaim excessively leaked memory/swap |
| 29 | launchd.daemons.fseventsd-reclaim = { |
| 30 | script = '' |
| 31 | killall -9 fseventsd |
| 32 | ''; |
| 33 | serviceConfig.StartInterval = 3600; |
| 34 | }; |
| 35 | } |