https://nixos.org/manual/nix/stable/command-ref/nix-collect-garbage#description
The command
nix-collect-garbage
is mostly an alias ofnix-store --gc
. That is, it deletes all unreachable store objects in the Nix store to clean up your system.However, it provides two additional options,
--delete-old
and--delete-older-than
, which also delete old profiles, allowing potentially more store objects to be deleted because profiles are also garbage collection roots. These options are the equivalent of runningnix-env --delete-generations
with various augments on multiple profiles, prior to runningnix-collect-garbage
(or justnix-store --gc
) without any flags.Note
Deleting previous configurations makes rollbacks to them impossible.
These flags should be used with care, because they potentially delete generations of profiles used by other users on the system.