Feature request: --delete-generations with --keep-booted #723

Closed
opened 2025-03-10 17:35:07 +00:00 by jbgi · 1 comment

From time to time I notice that I lost my currently booted generation when nix-env --delete-generationsing, because I had so many nixos-rebuild switch in between that I removed the old ones (I usualy keep 5-10 generations).

It would be a nice feature to have a flag to remove generations, but keep the currently booted one (as one can be sure that it works).

Describe the solution you'd like

--keep-booted flag (for nix-env and nic-collect-garbage) that would prevent deleting any /nix/var/nix/profiles/system-*-link symlink that would point to the same as /run/booted-system

Even better (but would break current behavior) would be that --keep-booted would be default behavior (so no need to add flag). Because I don't see any any drawback to always keep it (since it's a gc root anyway)

Additional context

Port of https://github.com/NixOS/nix/issues/1095

## Is your feature request related to a problem? Please describe. From time to time I notice that I lost my currently booted generation when nix-env --delete-generationsing, because I had so many nixos-rebuild switch in between that I removed the old ones (I usualy keep 5-10 generations). It would be a nice feature to have a flag to remove generations, but keep the currently booted one (as one can be sure that it works). ## Describe the solution you'd like `--keep-booted` flag (for `nix-env` and `nic-collect-garbage`) that would prevent deleting any `/nix/var/nix/profiles/system-*-link` symlink that would point to the same as `/run/booted-system` Even better (but would break current behavior) would be that `--keep-booted` would be default behavior (so no need to add flag). Because I don't see any any drawback to always keep it (since it's a gc root anyway) ## Additional context Port of https://github.com/NixOS/nix/issues/1095
Owner

that's not a problem lix can solve but something nixos must do. --keep-booted absolutely not going to happen because it's overly specific and ill-defined. the better option here would be for nixos to add a second profile (booted-system or something) and updating it only on reboots, which will both solve your immediate problem and possibly even give you a booted-generation log for times when you know that reboot three generations ago worked fine. you could even add such generation maintenande in an activation script.

that's not a problem lix can solve but something nixos must do. `--keep-booted` absolutely not going to happen because it's overly specific and ill-defined. the better option here would be for nixos to add a second profile (`booted-system` or something) and updating it only on reboots, which will both solve your immediate problem *and* possibly even give you a booted-generation log for times when you know that reboot three generations ago worked fine. you could even add such generation maintenande in an activation script.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#723
No description provided.