Why and how nix-shell uses tmpfs?

When I use nix-shell and I have to install packages on the fly (e.g. with pip install), I get “No space left on device” errors if the package is larger than ~780MB, even when I have GBs of free space in my disk.

After googling and inspecting disk usage, the cause seems to be that the package is downloaded or installed in a tmpfs partition, which only contains ~780MB of space.

I’ve spent multiple days trying to understand this, but I am still very confused:

  • When does nix-shell uses tmpfs? Is it used for everything, or just for downloading packages?
  • Can I change the size of this tmpfs partition?
  • Can I tell nix-shell to just use my computer’s main partition?
  • Which part of the nixpkgs code controls this tmpfs?
  • Where can I learn more about this?

Thanks!

It will use it when building some dependency that cannot be obtained from binary cache, like nix-build would.

I think this might be platform-specific. On my Ubuntu machine, Nix uses $XDG_RUNTIME_DIR, which size can be configured using RuntimeDirectorySize in /etc/systemd/logind.conf.

2 Likes