Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep last "known good" profile when running nix-collect-garbage #5818

Open
l0b0 opened this issue Dec 22, 2021 · 4 comments
Open

Keep last "known good" profile when running nix-collect-garbage #5818

l0b0 opened this issue Dec 22, 2021 · 4 comments

Comments

@l0b0
Copy link
Contributor

l0b0 commented Dec 22, 2021

Is your feature request related to a problem? Please describe.

Running with the --delete-old flag makes any rollback impossible, which is risky. And picking a reasonable --delete-older-than period to keep at least N profiles while reducing disk usage as much as possible means having to look through the list of generations to work out the amount of time since the last N builds and running with that plus a bit of a margin. This is cumbersome.

Describe the solution you'd like
The ideal solution would keep only the last known good profile plus the current profile. That way a working fallback is always available, and I can still attempt booting into the new (untested) profile, while ensuring minimal disk use.

This might be complicated to achieve, especially since "known good" is hard to pin down even for system profiles. For example, a system might boot, and might even start an X server, only to consistently crash a few seconds later due to a video driver bug (this happened to me recently).

A good enough solution might be a flag to keep the last N profiles.

How this interacts with --delete-old and --delete-older-than is probably not that important.

@grahamc
Copy link
Member

grahamc commented Dec 23, 2021 via email

@vcunat
Copy link
Member

vcunat commented Dec 27, 2021

[...] look through the list of generations to work out the amount of time since the last N builds and running with that plus a bit of a margin. This is cumbersome.

Workaround: if you go to such lengths, I'd rather just "manually" delete the symlinks according to your wishes. (And it's quite easy to script one-liners for last-N, etc.)

@stale
Copy link

stale bot commented Jul 10, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Jul 10, 2022
@stale stale bot removed the stale label Dec 5, 2022
@cnnrro
Copy link

cnnrro commented Mar 1, 2023

A good enough solution might be a flag to keep the last N profiles.

Another workaround for this particular solution:

You can garbage collect all but the last N system profiles by running: nix-env --profile /nix/var/nix/profiles/system --delete-generations +N 1 followed by the usual nix-collect-garbage.

A simple maintenance script might look something like:

nix-env --profile /nix/var/nix/profiles/system --delete-generations +5
nix-collect-garbage
nix-store --optimise

Footnotes

  1. https://nixos.org/manual/nix/stable/command-ref/nix-env.html#operation---delete-generations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants