nix
nix copied to clipboard
nix-collect-garbage: Allow number of generations to be specified rather than age
This is useful for scenarios where you want to ensure N generations are available for roll-back and all others are deleted to free up space.
Motivation
Implements #9455.
Context
See #9455.
Priorities and Process
Add :+1: to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.
--delete-older-than +Nisn't very intuitive, so it's probably better to have a different flag for this, e.g.--keep N.- This functionality should also be exposed by
nix profile wipe-history, since we want the new CLI to have feature parity with the old one. - There should be a test for this.
See also https://github.com/NixOS/nix/pull/9894
Any reason this isn't merged? Having the same option as in nix-env would be helpful.
The manpage mentions this feature should already exist as it says:
This is the equivalent of invoking
nix-env --delete-generations <period>on each found profile. See the documentation of that command for additional information about the period argument.
It would be good to get this PR in or change the docs to avoid confusion.
I would appreciate it if these specifying age and number of generations were not mutually exclusive. In particular, I'd like to be able to specify "delete all generations older than X days, but make sure at least N generations are kept". This would make more sense with a separate flag, like the aforementioned --keep.
There is a bit of an issue here with ambiguity on what it means to specify both ("both" or "either"), but since "either" can easily be achieved by just running the command twice, I don't think that this is a significant problem.
There is a bit of an issue here with ambiguity on what it means to specify both ("both" or "either"), but since "either" can easily be achieved by just running the command twice, I don't think that this is a significant problem.
The nix.gc service only runs it once, so having the ability to specify "either" is still important for that.