1.9 KiB
1.9 KiB
i-am-gcroot
Go tool (TUI via bubbletea, optional htmx web UI) to list, filter and delete Nix GC roots. User docs are in README.md.
Layout
main.go: subcommands (tuidefault,list,rm,gc,web,version) with stdlibflag.internal/roots: discovery (scan.go, mirrorsfindRootsin libstoregc.cc: gcroots tree +auto/indirect roots + profiles dir; runtime roots vianix-store --gc --print-roots),Set(thread-safe shared state used by TUI and web, background size computation),size.go(nix path-info --json -S, accepts both object and array JSON formats),delete.go(only removes symlinks; profile generations vianix-env --delete-generations; protected roots needForce),collect.go(targeted GC: closure of deleted targets minus closure of all--print-rootstargets, thennix-store --delete, retrying without paths nix reports alive).Root.Hiddenmarks nix cache roots (hiddenPatternsinscan.go);filter.Applydrops them unlessshowHiddenor the query hasis:hidden.internal/filter: query language and sorting shared by all frontends.internal/tui: bubbletea model (model.go) and rendering (view.go).internal/web: HTTP server,templates/index.html(page +rowsfragment),static/htmx.min.js(vendored htmx 2.0.4, embedded).nix/vm-test.nix+nix/vm-test.py: NixOS VM integration test. The Python lives in its own file because nix''strings do not strip tab indentation.
roots.Config holds store/state dirs and binary names so tests run against a fake tree in a temp dir.
Development
nix develop # go, gopls (CGO_ENABLED=0)
go test ./...
nix build # runs go tests too
nix build .#checks.x86_64-linux.vm -L # VM test
nix flake check
When Go dependencies change, set vendorHash in flake.nix to a fake hash, run nix build, and copy the got: hash. Nix files are indented with tabs.