Add a way to recursively GC paths
Motivation
Refactor GCOptions to make the types reflect possible GC operations, add a way to delete a specific path recursively, and add a --recursive flag to nix store delete.
Context
Fixes https://github.com/NixOS/nix/issues/7239
Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
- [ ] agreed on idea
- [ ] agreed on implementation strategy
- [ ] tests, as appropriate
- functional tests -
tests/**.sh - unit tests -
src/*/tests - integration tests -
tests/nixos/*
- functional tests -
- [ ] documentation in the manual
- [ ] documentation in the internal API docs
- [ ] code and comments are self-explanatory
- [ ] commit message explains why the change was made
- [ ] new feature or incompatible change: updated release notes
Priorities
Add :+1: to pull requests you find important.
Can't this be done using nix-store --delete $(nix-store -qR <path>)?
Can't this be done using nix-store --delete $(nix-store -qR
)?
AFAIU in that case the entire operation will fail if at least one path in the closure is still alive. This PR adds a way to remote all dead paths in a closure. I should clarify that in the documentation.
This pull request has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/tweag-nix-dev-update-49/29047/1
Still didn't manage to review this (sorry about that, I've blocked an hour tomorrow afternoon for it), but one thing I can say any way is that it will require tests and documentation
This pull request has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/tweag-nix-dev-update-50/29793/1
Just to reassure myself: this covers the use case of release version pinning while using the nix store as backend, right?
(By sort of inverting the logic)
Thanks a lot for doing this!
@balsoft any chance to rebase and squash?
@domenkozar thanks, done
This pull request has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2023-08-04-nix-team-meeting-minutes-77/31487/1
Whats the status for this?
@balsoft this PR doesn't work yet, do you plan to work on it?
Yep. I'm planning to finish the work at some point, definitely.
@balsoft still the plan?
Yep! Currently tied up on https://github.com/NixOS/nix/pull/9287 , once that's done-ish I'll get back to other PRs including this one!
I've rewritten it a bit to make it less invasive (kept the original changes under https://github.com/tweag/nix/commits/gc-closure_ because the cleanup of GCOptions is rather nice and it would be good to come back to it later).
I've also changed the interface to use nix store gc <installable> instead as that felt more coherent
This pull request has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/tweag-nix-dev-update-55/40996/1
I've found a bug:
❯ nix store gc /nix/store/w53sjb6pmzdqfcflh92rlmjfzz6xbc33-devenv-shell-env
error:
error: unexpected argument '/nix/store/w53sjb6pmzdqfcflh92rlmjfzz6xbc33-devenv-shell-env'
Try '/nix/store/a0i9g29xgmk42gjjglzd6k0kzyjkay3n-nix-2.21-devenv/bin/nix --help' for more information.
Where '/nix/store/w53sjb6pmzdqfcflh92rlmjfzz6xbc33-devenv-shell-env is a derivation for nix-shell.
I've also changed the interface to use nix store gc
instead as that felt more coherent
I would prefer a different command for that, e.g. nix store delete-path .... Apart from being clearer (you're not doing a GC but deleting a specific path), overloading a command to either delete everything or some paths has the problem that shell code like
nix store gc "${paths[@]}"
will do a full GC if the paths array is empty, which is probably not intended.