Skip to content

Maintenance

Marcus Whybrow edited this page Nov 21, 2024 · 3 revisions

Reducing Disk Usage

sudo nix store gc --verbose

Will remove (garbage collect) all unused Nix packages in /nix/store.

Packages are considered active if they are part of a package linked in /var/nix/profiles. Each link constitutes a "generation" of the system which may be ran, and all packages required by a generation are considered active, and not deleted by Nix Store garbage collection.

List extant generations using ls -tl /var/nix/profiles.

Unlink any superfluous generation using, say, sudo unlink /var/nix/profiles/system-3-link.

Run sudo nix store gc --verbose again to remove any newly inactive packages from /nix/store.

Shrinking WSL Disks

If your NixOS is hosted inside of WSL (Windows Subsystem for Linux) then Windows will receive no space savings despite NixOS now showing free disk space. WSL cannot automatically shrink virtual disks, it can only automatically grow them. To reclaim the free space manually, do the following in the Windows Command Prompt.

wsl --shutdown
diskpart
select vdisk file="C:\Users\marcus\NixOS\ext4.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit
Clone this wiki locally