-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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. |
Code looks pretty good to me. While this is an old and deep-rooted feature surface, testing it reliably is probably at least as much work as coming up with the change. To avoid this change getting stale, I'd prefer merging it as is, and betting on @MichaelOultram to catch up with tests, and betting on the upcoming STF grant as a fallback. @Ericson2314 what do you think? |
e9b602e
to
d1cc2e9
Compare
I wrote that back in February... oops 😅. Sorry for the delay. I've rebased the branch to the latest master, and the existing tests still pass locally. I still have ambitions to add extra tests, but I've not been able to achieve this today. I'll mark this PR as ready if it makes it easier to merge these changes as is. I'll either continue to add the tests to this PR, or open an another PR specifically for the extra tests if this one gets merged. Either option is good with me. |
Looks like I managed to push during a GitHub actions incident: https://www.githubstatus.com/incidents/lfrlwdg67fn8. Can you press the retry buttons as I don't think I have permission to? |
EDIT: the macos CI job was rerun and it completed in 23m 57s so I'm assuming the timeout issue on the previous run was just a slow worker Original CommentI'm still struggling to figure out why the CI is failing on this PR. The First irregularity I found with my run a
But this stall alone wouldn't be enough to hit the timeout. I couldn't spot any other long pauses in the logs, but it just feels like everything is running slower in my PR run for some unknown reason. For example, if we only look at the lines with my PR run:
passing run:
So my PR took Either I've been super unlucky with the CI and ended up on a worker that has approximately half the performance, or my changes have somehow regressed the performance significantly. |
I'm quite happy now about the test coverage of this changeset for specifically the I'd like to add similar tests for |
I believe the tests I've written suitably cover the changes I've made. I've got no more planned commits for this PR and so await feedback. |
* check exact generation ids instead of just the count * test --delete-older-than days
Extend all tests to include tests where the active generation is not the latest generation.
ed27a88
to
19514f6
Compare
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.