automatic-gc: ability to configure number of profiles to retain, instead of age

#435
Opened by tazjin at 2025-01-15T15·38+00

As sterni pointed out in https://cl.tvl.fyi/c/depot/+/12997/1/ops/machines/bugry/default.nix#181 our automatic-gc configuration with the profiles to keep by age might not actually lead to a useful "window".

We might want to support a number of profiles to keep instead, though I'm not sure if the underlying mechanism lets us do this easily, or if we need to do it manually.

  1. nix-env can do this via --delete-generations '+<NUM TO KEEP>', however it doesn't seem like C++ Nix hasn't reimplemented this feature for nix-collect-garbage, so we'd need to reimplement it in our script….

    sterni at 2025-01-15T19·57+00