Allow garbage-collecting a closure#15236
Conversation
86012d3 to
2f34a72
Compare
8f3db57 to
34bc281
Compare
6082386 to
38782d1
Compare
e9bb1d4 to
1b5a1b2
Compare
1b5a1b2 to
e93193b
Compare
xokdvium
left a comment
There was a problem hiding this comment.
Makes sense to me. Nice that we can hack it in without changing the actual worker protocol too much.
|
@roberth I am trying to remember the CLI guidelines. Should this be |
Maybe |
02002bb to
395130a
Compare
| // This violates the convention that an empty `pathsToDelete` corresponds | ||
| // to the whole store, but deleting the whole store doesn't make sense, | ||
| // and `nix-store --delete` is a valid command that deletes nothing, so | ||
| // we need to keep it as-it-is. | ||
| return; |
There was a problem hiding this comment.
So basically we maintain the invariant that an added installable increases the number of candidates to try delete?
I agree it's the more expected and safer behavior.
| input0=$(realpath "$TEST_ROOT/gc-root") | ||
| input1=$(nix build -f dependencies.nix input1_drv --no-link --print-out-paths) | ||
| input2=$(nix build -f dependencies.nix input2_drv --no-link --print-out-paths) | ||
| top=$(nix build -f dependencies.nix --no-link --print-out-paths) |
There was a problem hiding this comment.
Related
Its implementation could drop the --no-link here.
No action required.
|
|
||
| if (!options.pathsToDelete.empty() && options.action == GCAction::gcDeleteDead | ||
| && !conn.protoVersion.features.contains(WorkerProto::featureGcClosure)) { | ||
| throw Error("Garbage collecting a closure requested but it is not supported by the negotiated protocol"); |
There was a problem hiding this comment.
The way I understand it, this is near-unreachable and only a nix-as-client logic error would trigger this?
There was a problem hiding this comment.
Yeah, I don't think this is reachable currently and would only happen due to a future introduced logic error
efeb271 to
b93025d
Compare
f882069 to
1f94c57
Compare
1f94c57 to
2518146
Compare
| auto store = openStore(); | ||
| auto & gcStore = require<GcStore>(*store); | ||
| options.action = dryRun ? GCOptions::gcReturnDead : GCOptions::gcDeleteDead; | ||
| options.pathsToDelete = GCOptions::WholeStore{}; |
There was a problem hiding this comment.
Nice, I like how it forces us to be explicit!
d1e26a4 to
5033d29
Compare
5033d29 to
31e7b96
Compare
31e7b96 to
1bffeb1
Compare
This allows garbage collecting a closure. `nix store delete --recursive --skip-alive` is morally equivalent to ```bash for validPath in $(nix path-info --recursive foo); do nix store delete "$validPath" || true done ``` Resolves NixOS#7239 Co-authored-by: Théophane Hufschmitt <theophane.hufschmitt@tweag.io> Co-authored-by: Alexander Bantyev <balsoft@balsoft.ru> Signed-off-by: Lisanna Dettwyler <lisanna.dettwyler@gmail.com>
1bffeb1 to
dc83e83
Compare
Add option
--skip-alivetonix store deletenix store delete --recursive --skip-aliveis morally equivalent toAlso adds utility functionwill be split off into separate PRnix dev-env-pathto facilitate use with devShells.Resolves #7239
Motivation
This is the most requested unresolved feature in Nix. (https://github.com/NixOS/nix/issues?q=is%3Aissue%20state%3Aopen%20sort%3Areactions-%2B1-desc)
Context
#7239
Replaces #8417 because the author appears to have stopped working on it years ago.
This is a separate command to avoid the pitfall of
nix store gc $(getSomePaths)resolving tonix store gc, which would unintentionally GC the entire store.Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.