Nix Installation and Memory Issues

I’ve had nix on all my machines for a while, and I’ve even had nix on this machine.
I’ll list the things I’ve tried at the bottom, but this image is a good summary of all attempts

  • I hit a weird bug of saying its out of storage even though there was >8Gb left.
  • I decided to reinstall nix to try and fix the problem
    • For Linux I have a very comprehensive uninstall script (users/groups/services/files/processes)
    • I run it every time, and I also clear all ENV vars related to nix before trying a fresh install
  • I’ve installed

All of them result in strange and very similar issues. Sometimes nix-env -i cowsay will be killed by the system (as in Killed is the only thing printed), sometimes it noisily runs out of ram, and last it will sometimes give me the original error where it gets to the build stage and then says there’s no-space available despite the server having 8.6Gb of free storage. The docker container gets repeated “GC Warning” issues during the installation phase.

I installed nix on this machine at least a year ago, and I have no idea what’s causing it to suddently fail. I’ve power cycled, killed/stopped all non-system-vital processes and services, and purged every reminant of nix from the machine. Has any one hit similar issues recently?

Well thanks to some more trouble shooting, the question has now become “why does nix need more than half a Gig of ram just to install cowsay”. I cofirmed on normal machine running docker that having less than two gigs of ram sometimes produces the similar results, increasing the ram to 3Gb with 1 Gb of swap in Docker lets me reliably install cowsay.

My server is just a lightweight static file server with 1Gb of ram, but I had used nix to manage dependencies. I’m not sure what changed that makes it consume more ram. Adding 4Gb of swap seemed to do the trick. Nice guide here for anyone also hitting this issue.

1 Like

running just nix-env -i requires looking through all packages to match that name, which is very expensive as you’ve noted. nix-env -iA nixpkgs.cowsay installs the same package but uses a fraction of the resources to do it, since you’re giving the exact attribute path (-A) to the derivation.

5 Likes

Thank you! I’ll test this out and compare memory usage next time I’m pushing to the server