-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(nix-collect-garbage): allow trimming generations both by count and by date #14007
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds new flags --keep-min
and --keep-max
to nix-collect-garbage
to provide more precise control over generation deletion by allowing trimming both by count and by date.
- Adds
--keep-min
and--keep-max
flags for count-based generation management - Implements a new
deleteGenerationsFilter
function to handle complex deletion logic with both time and count constraints - Updates documentation with examples showing how to combine time and count-based deletion
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/nix/nix-collect-garbage/nix-collect-garbage.cc | Adds new command-line flag parsing for --keep-min and --keep-max options |
src/libstore/profiles.cc | Implements the core deleteGenerationsFilter function and refactors existing deletion functions to use it |
src/libstore/include/nix/store/profiles.hh | Adds function declaration and comprehensive documentation for the new deletion API |
src/libmain/include/nix/main/shared.hh | Enhances getIntArg function to support parsing integers without unit suffixes |
doc/manual/source/command-ref/nix-collect-garbage.md | Updates documentation with new flag descriptions and usage examples |
Comments suppressed due to low confidence (1)
src/nix/nix-collect-garbage/nix-collect-garbage.cc:1
- Missing space before opening brace. Should be
} else if (*arg == "--keep-max") {
to maintain consistent formatting with other conditional blocks.
#include "nix/util/file-system.hh"
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that this is a useful addition.
Motivation
I would like to run garbage collection automatically, but I find flags given to
nix-collect-garbage
to be imprecise:This PR adds 2 new flags,
--keep-min
and--keep-max
:keep-max
by itself allows deleting by amount,--keep-max 5
will preserve current generation and 5 most recent old oneskeep-min
andkeep-max
both work in conjunction withdelete-older-than
, working as bounds on how many generations should be preserved.Context
Solves #9455 and builds upon feedback given to #10426.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.