Forrest logo
back to the nix-collect-garbage tool

nix-classic:tldr:045c4

nix-classic: Remove unused paths from Nix store.
$ nix-collect-garbage
try on your machine

The command nix-collect-garbage is used in the Nix package manager to clean up unused files and free up disk space. When packages are updated or removed, Nix keeps the old versions around in case they are still needed by other packages. Over time, these old versions can accumulate and take up a significant amount of disk space.

The nix-collect-garbage command identifies and removes these unused files. It scans the Nix store, which is where all installed packages are stored, and identifies any unreferenced or older versions of packages that are no longer needed. It then deletes these files, reclaiming disk space.

By running nix-collect-garbage, you can free up space taken by old package versions that are no longer required by any packages on your system. This is particularly useful if you often install and uninstall packages or regularly update your packages.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the nix-collect-garbage tool