Nix: Feature request: --delete-generations with --keep-booted

Created on 18 Oct 2016  路  8Comments  路  Source: NixOS/nix

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).

feature

Most helpful comment

Maybe one fix is to have NixOS set up a separate booted profile next to the system profile, updating it (without increasing the generation) on each boot. Then that profile won't be "old" ever, and we just have to teach the boot loader entry script to respect that profile too.

All 8 comments

It's unclear to me what "booted" means in connection with nix-env generations.

Well, it does apply at least to nix-collect-garbage -d, I think.

It's unclear to me what "booted" means in connection with nix-env generations.

I mean the /run/booted-system generation.

And that's managed by nix-env? I've never done it with anything but nixos-rebuild etc.

BTW, nix counts lots of things as GC roots, including the booted system, IIRC, so it shouldn't delete anything else but the first symlink.

including the booted system, IIRC

I don't think so... as said, I ended up with generations (for example) 140-147, but booted was generation 138... so I guess the booted system is not a GC root ...

I didn't mean it wouldn't delete the generation link; I meant it shouldn't remove anything referenced by /run/booted-system (which points to the same path as that deleted generation link).

Ah, yeah. No these things are not deleted, _but_ the boot entry is removed. And if my new generations do not boot anymore (for whatever reasons), I cannot boot in the last booted generation. You see what I mean?

Maybe one fix is to have NixOS set up a separate booted profile next to the system profile, updating it (without increasing the generation) on each boot. Then that profile won't be "old" ever, and we just have to teach the boot loader entry script to respect that profile too.

Was this page helpful?
0 / 5 - 0 ratings