![Forrest logo](/images/logo.png)
nix-classic:tldr:045c4
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.