nix-community / nix-emacs

A set of useful Emacs modes and functions for users of Nix and Nix OS.
226 stars 32 forks source link

Disk space leak in successive calls to nix-shell #21

Closed svenkeidel closed 8 years ago

svenkeidel commented 8 years ago

I use nix-sandbox.el at work and encountered an issue. After a few hours of work, my machine told me that my disk space is nearly full. As it turns out, it was the /nix/store directory, so I did a nix-collect-garbage and cleaned up ~80Gb disk space. After a few hours more, the issue reappeared. The reason for this massive growth in space are successive calls to nix-shell --run .... Each call creates a new derivation, which then takes up some space on disk and doesn't get deleted after nix-shell exits.

So question is, how do we fix this? I see the following solutions:

  1. Reuse nix-shell sessions for successive calls.
    • Pro: Commands that are executed in quick succession don't get the overhead of nix-shell --run calls.
    • Con: Requires external tooling to get the process abstraction back. This would involve the creation of a nix-shell daemon and a nix-shell client tool.
  2. Cleanup after nix-shell calls.
    • Pro: probably easier to implement
    • Con: doesn't fix the nix-shell call overhead.

I for my part am in favor of the first solution. I also would do the development effort since I'm in a desperate need for a solution. What is your opinion?

Best, Sven

svenkeidel commented 8 years ago

Third solution, rewrite this script in elisp.

CestDiego commented 8 years ago

I'm also couching for the first solution. But the second one is also okay if you desperately need it On Dec 18, 2015 3:54 PM, "Sven Keidel" notifications@github.com wrote:

Third solution, rewrite this https://github.com/NixOS/nix/blob/master/scripts/nix-build.in script in elisp.

— Reply to this email directly or view it on GitHub https://github.com/travisbhartwell/nix-emacs/issues/21#issuecomment-165895751 .

vyp commented 8 years ago

FWIW, same thoughts as @CestDiego.