Rebuilding when disk is full

I’m running NixOS on a small VPS with 40GB disk space that is currently out of space. I’ve changed my config to remove some unused options and packages to clear disk space, and added a new one, but since there’s no disk space left I can’t complete the rebuild.

I’ve attached a temporary volume of 20GB in hopes I can mount the nix store there, but I’m not sure if this is recommended to do so. mount --bind /mnt/nix /nix rendered my machine unusable.

Any advice for course of action?

You could try to free just enough to be able to use Nixos tools again:

journalctl --disk-usage
sudo journalctl --rotate --vacuum-time=1s --vacuum-files=1

Then, remove all previous generations:

sudo nix-collect-garbage -d

and optimise /nix/store/ with:

sudo nix-store --optimise
1 Like

I would try rebuilding a smaller config from the same old revision (so that it doesn’t add any new versions of software)

Thank you, these were useful.

1 Like