Packages that are installed but not used may be garbage-collected.
guix gc command allows users to explicitly run the garbage
collector to reclaim space from the /nix/store directory.
The garbage collector has a set of known roots: any file under
/nix/store reachable from a root is considered live and
cannot be deleted; any other file is considered dead and may be
deleted. The set of garbage collector roots includes default user
profiles, and may be augmented with
guix build --root, for
example (see Invoking guix build).
Prior to running
guix gc --collect-garbage to make space, it is
often useful to remove old generations from user profiles; that way, old
package builds referenced by those generations can be reclaimed. This
is achieved by running
guix package --delete-generations
(see Invoking guix package).
guix gc command has three modes of operation: it can be
used to garbage-collect any dead files (the default), to delete specific
--delete option), or to print garbage-collector
information. The available options are listed below:
Collect garbage—i.e., unreachable /nix/store files and sub-directories. This is the default operation when no option is specified.
When min is given, stop once min bytes have been collected.
min may be a number of bytes, or it may include a unit as a
suffix, such as
MiB for mebibytes and
GB for gigabytes.
When min is omitted, collect all the garbage.
Attempt to delete all the store files and directories specified as arguments. This fails if some of the files are not in the store, or if they are still live.
Show the list of dead files and directories still present in the store—i.e., files and directories no longer reachable from any root.
Show the list of live store files and directories.
In addition, the references among existing store files can be queried:
List the references (respectively, the referrers) of store files given as arguments.
List the requisites of the store files passed as arguments. Requisites include the store files themselves, their references, and the references of these, recursively. In other words, the returned list is the transitive closure of the store files.