Nixos-rebuild failing with “out of memory”

Since I upgraded to 20.09 nixos-rebuild is consistently failing with on “out of memory”message. Has anyone else encountered this issue? How do I fix?


you could follow to create a temporary swap file, turn it on, then complete the upgrade.

just curious, how much RAM is available?

I did not encounter such issues. Can you paste the output of

# free -h

, please? That would give us information about your available RAM.
What exactly do you mean by “upgrade”, how did you start that process?

I issued the following three (3) commands:

  1. nix-channel —add nixos
  2. nix-channel —update
  3. nixos-rebuild switch —upgrade

Sometime afterwards I rebooted the machine and added (mosh I think it was?) to my configuration.nix. When I did ‘nixos-rebuild test && nixos-rebuild boot’ to test the new config, I see

building Nix…
building the system configuration…
error: out of memory

Thanks for the quick reply. I have 7.2Gi free before nixos-rebuild and 7.1Gi afterwards. I have 11Gi of swap with 0B used.

Can you please tell us what version of nix you currently have?

Also please use --verbose when running the nixos-rebuild, I had a lot of trouble with a VM of mine, which I pushed to 200 GiB of Memory through swap but still failed to rebuild, because it got killed…

I didn’t see the OOM error in my case, just that it failed with a non-zero exit-code (which I do not remember anymore).

--verbose showed that it always failed while evaluating modules.nix or something like that.

That was with nix 2.3.6 on 20.03.

I wasn’t even able to update to 2.3.7 due to that. What helped in my case was to use a nix-shell that had nixUnstable available, then I was able to rebuild the systems configuration, I fast forwarded that machine to 20.09 as well.

I do not have any issues since then anymore.