I have just read about using NixOS with tmpfs root and tmpfs home which looks very interesting to me, however I feel like it is too much to begin with. So my question is, can I somehow replicate it with containers, especially with regards to development environments?
My use-case is: I often contribute to projects just once or very sporadically. It is often that someone writes me Could you please have a look at this project and do this or that modification? I clone their project, understand their dev tools and set it up using
nix-shell -p … or writing down
shell.nix. So far it is just great and nix saved me a lot of time. However the problem is, many of the tools used a stateful. NPM/Composer manages its cache in the home directory for example. So after running
npm install my disk space shrinks and is not released after being done with the project a deleting it.
Before switching to NixOS, I was using Docker to fight this problem. I just spawned a clean image and mounted the code there. I then installed all the deps otherwise filled the container with garbage. But thanks to the nature of containers, it was all gone when I deleted it.
Is there a better, pure Nix way? My idea is setting up an imperative container with the project mounted into it and having everything inside mounted with a tmpfs overlay or tmpfs over the home dir and everything else as read only or so. I could find some mentions about containers
ephemeral option, but without any details.
I have also come across nixos-shell, however the last commit is 6 year ago and there seems to be no community nor any docs. Is is usable for this kind of problem?
How do you personally do development not to fill your machine with garbage?
Thanks in advance