| nix-store --gc(1) | General Commands Manual | nix-store --gc(1) |
nix-store --gc - run garbage collection
nix-store --gc [--print-roots | --print-live | --print-dead] [--max-freed bytes]
Without additional flags, the operation --gc performs a garbage collection on the Nix store. That is, all paths in the Nix store not reachable via file system references from a set of “roots”, are deleted.
The following suboperations may be specified:
By default, all unreachable paths are deleted. The following options control what gets deleted and in what order:
The behaviour of the collector is also influenced by the keep-outputs and keep-derivations settings in the Nix configuration file.
By default, the collector prints the total number of freed bytes when it finishes (or when it is interrupted). With --print-dead, it prints the number of bytes that would be freed.
{{#include ./opt-common.md}}
{{#include ../opt-common.md}}
{{#include ../env-common.md}}
To delete all unreachable paths, just do:
$ nix-store --gc deleting `/nix/store/kq82idx6g0nyzsp2s14gfsc38npai7lf-cairo-1.0.4.tar.gz.drv' ... 8825586 bytes freed (8.42 MiB)
To delete at least 100 MiBs of unreachable paths:
$ nix-store --gc --max-freed $((100 * 1024 * 1024))