| nix-env --delete-generations(1) | General Commands Manual | nix-env --delete-generations(1) |
nix-env --delete-generations - delete profile generations
nix-env --delete-generations generations
This operation deletes the specified generations of the current profile.
generations can be a one of the following:
Periodically deleting old generations is important to make garbage collection effective. The is because profiles are also garbage collection roots — any store object reachable from a profile is "alive" and ineligible for deletion.
{{#include ./opt-common.md}}
{{#include ../opt-common.md}}
{{#include ./env-common.md}}
{{#include ../env-common.md}}
$ nix-env --delete-generations 3 4 8
Delete the generations numbered 3, 4, and 8, so long as the current active generation is not any of those.
$ nix-env --delete-generations +5
Suppose 30 is the current generation, and we currently have generations numbered 20 through 32.
Then this command will delete generations 20 through 25 (<= 30 - 5), and keep generations 26 through 31 (> 30 - 5).
$ nix-env --delete-generations 30d
This command will delete all generations older than 30 days, except for the generation that was active 30 days ago (if it currently exists).
$ nix-env --profile other_profile --delete-generations old