Storage optimization: Difference between revisions
imported>Appetrosyan Consistency improvements, style. Used more templates. All commands now have the appropriate privilege indicator. |
imported>Samuela No edit summary |
||
| Line 91: | Line 91: | ||
Look for system derivations in particular. Those are created on many occasions, for example when running <code>nixos-rebuild build-vm</code> | Look for system derivations in particular. Those are created on many occasions, for example when running <code>nixos-rebuild build-vm</code> | ||
=== Removing old generations === | |||
NixOS keeps old configurations of your system around so that you can always rollback to a previous configuration if something goes wrong. You can also select which generation to boot into via GRUB. | |||
However these previous generations are GC roots that can keep around old, unnecessary software in your nix store. You can check what system generations you have with | |||
<syntaxhighlight lang="console"> | |||
$ sudo nix-env -p /nix/var/nix/profiles/system --list-generations | |||
... | |||
58 2021-09-04 02:56:54 | |||
59 2021-09-05 07:12:43 | |||
60 2021-09-05 22:12:13 (current) | |||
</syntaxhighlight> | |||
You can remove all but the current generation with | |||
<syntaxhighlight lang="console"> | |||
$ sudo nix-collect-garbage -d | |||
... | |||
4394 store paths deleted, 3467.28 MiB freed | |||
</syntaxhighlight> | |||
There are also user-specific generations for different things (eg. home-manager). These can be removed with | |||
<syntaxhighlight lang="console"> | |||
$ nix-collect-garbage -d | |||
</syntaxhighlight> | |||
=== Reboot === | === Reboot === | ||