Skip to content
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

Garbage collect a closure #7239

Open
domenkozar opened this issue Oct 29, 2022 · 7 comments · May be fixed by #8417
Open

Garbage collect a closure #7239

domenkozar opened this issue Oct 29, 2022 · 7 comments · May be fixed by #8417
Assignees
Labels
feature Feature request or proposal idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome.

Comments

@domenkozar
Copy link
Member

domenkozar commented Oct 29, 2022

I'd like to give Nix a closure that I'd like to garbage collect leaf nodes up to the point it hits a live node.

Something like nix store delete --recursive <installable>.

@domenkozar
Copy link
Member Author

@edolstra shouldn't this delete the second path?

$ nix store delete /run/current-system /nix/store/2vigl5h3qja0ms9a4grbn7z71psz2vcl-abcl-1.9.0
0 store paths deleted, 0.00 MiB freed
error: Cannot delete path '/nix/store/zhx2jgcxczry9v3234viaywpc276ss2b-nixos-system-cherimoya-22.05pre-git' since it is still alive. To find out why, use: nix-store --query --roots

@domenkozar
Copy link
Member Author

Ohh, it does delete it but it says it didn't 😆

@edolstra
Copy link
Member

Really? That would be very bad.

@domenkozar
Copy link
Member Author

$ nix-store -r /nix/store/2vigl5h3qja0ms9a4grbn7z71psz2vcl-abcl-1.9.0
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/2vigl5h3qja0ms9a4grbn7z71psz2vcl-abcl-1.9.0

$ nix store delete /nix/store/2vigl5h3qja0ms9a4grbn7z71psz2vcl-abcl-1.9.0 /run/current-system
0 store paths deleted, 0.00 MiB freed
error: Cannot delete path '/nix/store/zhx2jgcxczry9v3234viaywpc276ss2b-nixos-system-cherimoya-22.05pre-git' since it is still alive. To find out why, use: nix-store --query --roots

$ nix-store -r /nix/store/2vigl5h3qja0ms9a4grbn7z71psz2vcl-abcl-1.9.0
this path will be fetched (10.09 MiB download, 13.55 MiB unpacked):
  /nix/store/2vigl5h3qja0ms9a4grbn7z71psz2vcl-abcl-1.9.0
copying path '/nix/store/2vigl5h3qja0ms9a4grbn7z71psz2vcl-abcl-1.9.0' from 'https://cache.nixos.org'...
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/2vigl5h3qja0ms9a4grbn7z71psz2vcl-abcl-1.9.0

@tpwrules
Copy link
Contributor

tpwrules commented Dec 20, 2022

Just to clarify, by closure, you mean you want to be able to automatically delete exactly those paths printed by nix-store -qR? It is confusing why you refer to "live nodes" here. Nothing in the closure of a live path could ever be deleted, correct?

EDIT: I see what you mean I think. Some paths printed by nix-store -qR might not be deletable because they are also in the closure of a live path. So you would want those would be skipped.

@domenkozar
Copy link
Member Author

@edolstra what do you think about this approach by @thufschmitt tweag@0bb351b

@thufschmitt thufschmitt added the idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. label Mar 24, 2023
@thufschmitt thufschmitt moved this to ⏰ Postponed in Nix team Mar 24, 2023
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-03-23-nix-team-meeting-minutes-43/26758/1

@balsoft balsoft linked a pull request May 30, 2023 that will close this issue
8 tasks
@thufschmitt thufschmitt removed this from Nix team Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants