Closed symphorien closed 1 year ago
Before looking at this PR, here’s an unprimed design mockup of what I’d expect the gc root cleaning CLI to look like:
lorri gc info
Shows info about projects (shell files) that exist and have been evaluated.
Shows info about which projects don’t have a corresponding directory (or just can’t be reached anymore)
--json
prints a json representation that can be parsed in scripts.
It contains
lorri gc rm --shell-file path/to/shell.nix --shell-file …
Removes any gc roots to the shell file, so that the next nix garbage collect removes the project store paths.
Removes the project from lorri’s database.
Afterwards runs nix-store --delete
on all drvs and store paths that we know about (how to determine? Do we have references to the store paths? Or do we need an extra nix-store --query
to find the paths?
Since there is no way to figure out if a drv has some IfD-paths it instantiates (is there?), we should print a message to run nix-store --gc
to remove all artifacts, also the ones from previous runs.
lorri gc rm --all
Removes all gc roots that were created by lorri.
Convenience for parsing gc info --json
and constructing a long gc rm
command line with all files.
lorri gc rm --older-than=\<days>
Removes all gc roots that haven’t been updated <days>
ago.
Convenience for parsing this information from the gc info --json
output and creating a gc rm
command line with all files.
I implemented something very close to what you proposed. Differences:
I rebased but ci fails because cachix/cachix-action is out of date.
I pushed a commit updating nix-related actions. It fixes CI on ubuntu at least.
could you review again, @Profpatsch ?
ping @Profpatsch
@symphorien Apologies for letting this linger so long. Could you merge canon back to your branch? Notably, the CI configs need to be updated (I think -X theirs
would work fine)
done
ci fixed :)
I copied the functionality and option names of
nix-store --gc --print-roots
andnix-collect-garbage --delete-older-than
. To print the original project a gc root corresponds to, I store a symlink to the shell.nix file along with the gc root.release.nix
(seerelease.nix
for instructions)