Smart boot environment garbage collection?


I was wondering if it was possible to improve the boot environments garbage collection in this way.
If I built the system with a pinned input (flakes or not), and build 4 different new environments with minors changes, could it be possible for the boot env trimming code to only account this as one?

I mean, I would like to keep the n-1 working boot environment, but if I try too much variations of a new env, it won’t take much disk space, but it will reach the limit of boot env and the working n-1 will be deleted. That’s not really smart :confused:

Well, the configurationLimit is passed to Grub via an XML file and processed here: nixpkgs/ at 6cf5d549fe1141250cf4df7ab3f3697ea984b4dc · NixOS/nixpkgs · GitHub

So, you can add the number of environments built from the same pinned input to the configurationLimit (it is up to you how to detect that) or add an option that does not have a fixed limit on entries but rather on free space on the boot partition (which is probably a non-trivial change to the perl script).

Adding things up: You probably need to hack a bit on that part of NixOS to get the desired functionality.

1 Like

Bootspec is being merged, if you are interested into cleaning up the existing bootloader script, you can get this feature quite easily :slight_smile:.