More fine grained control about garbage collection

I currently use nix-collect-garbage --delete-older-than 14d to delete old generations. For my user this works quite well, though for the system I do an update only one or two times a month, leading to the fact, that I often don’t have a previous generation to boot into.

This leads to the situation, that I could either use sudo with a larger timespan to keep, and then run a GC for each user individually with a short time span which would be tedious to do (even when scripted and/or croned).

Alternatively I could just use a longer timespan for all users, which would roughly double the required diskspace for the store (tried it for 2 months).

Then I could use the short timespan even for the system, but, yes, no previous generation then to boot into…

Therefore, I’d like to ask, if there is any option to say “keep at least 5 generations of each profile”. Plus points if I could combine it with --delete-older-than in a way, that I always have at least 5 generations, but a generation from the last 14 days get never deleted?

2 Likes