Forrest logo
back to the nix-store tool

nix-store:tldr:3aedb

nix-store: Collect garbage, such as removing unused paths.
$ nix-store --gc
try on your machine

The nix-store --gc is a command that is used in the Nix package manager to perform garbage collection.

In Nix, every package that is installed on the system is stored in the Nix store - a directory where all the packages are stored as unique entities based on their content hash. Over time, as new versions of packages are installed, older versions may become unused, leading to disk space wastage.

The --gc option stands for garbage collection, which is a process to remove any unreferenced or unused packages from the Nix store, freeing up disk space.

When you run nix-store --gc, Nix identifies and removes any packages that are not referenced by any other packages, thus eliminating unnecessary files and freeing up disk space. This command helps to keep the Nix store clean and efficient.

It is a good practice to periodically run nix-store --gc to ensure that your system does not accumulate unnecessary packages and uses disk space optimally.

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-store tool