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
Refactor generation deletion for better code reuse between CLI tools #9894
base: master
Are you sure you want to change the base?
Refactor generation deletion for better code reuse between CLI tools #9894
Conversation
Making the interface actually be in sync is a fine idea, but adding more Can you figure out why the commands supported different things in the first place? Answering that question will in turn tell use what code needs to change. |
@Ericson2314 yes I agree. That would be the better way to do this. I'm not much of a C++ programmer, and it's my first PR to this repo, so I went for the smaller diff. I'll mark this PR as a draft, and look into a better way to refactor this. |
in dcc433d, the In 034b6f6, the In 4ca5a9d, In 429154b, support for specifying the number of generations to keep was added to In 4b738fc, So my proposal is to add a new function into https://github.com/NixOS/nix/blob/master/src/libstore/profiles.cc which would accept the string parameter, and call the relevant |
4c3edca
to
ec5f27e
Compare
Sorry I missed this @MichaelOultram, great job with the deep dive there! |
ec5f27e
to
94085e4
Compare
94085e4
to
e9b602e
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-02-28-nix-team-meeting-129/40499/1 |
Current status: I believe I've fixed the bug that the first CI run picked up on. I'm leaving this as a draft PR as I'd like to spend a little more time looking if any tests can be added. |
Motivation
The
nix-env
command allows the user to specify the number of generations to keep using the--delete-generations
flag by prefixing the argument with a+
. This functionality was missing from thenix-collect-garbage
--delete-older-than
flag.As pointed out by @Ericson2314, simply adding this functionality to
nix-collect-garbage
would not be the right approach, and instead the logic should be shared between CLI tools.Context
From the
nix-collect-garbage
docs for the--delete-older-than
flag mention looking at thenix-env
docs to learn more about the<period>
argument.nix/doc/manual/src/command-ref/nix-collect-garbage.md
Lines 56 to 61 in 4072a8f
In the
nix-env
docs, it mentions that+
can be used to specify the number of generations to keep.nix/doc/manual/src/command-ref/nix-env/delete-generations.md
Lines 41 to 46 in 4072a8f
However, when I tried to use the
nix-collect-garbage
in this way, I got an error as the functionality was not implemented.Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.