I use a similar approach, but I went further by creating a system that compose like docker-compose would. The trick was to write my own nix function mergeShells
.
https://her.esy.fun/posts/0024-replace-docker-compose-with-nix-shell/index.html
For now, I am pretty happy with it. Also, I put the init script inside nix-shell and not in external files and use exit signal to cleanup the state.
nix does not need nixOS to run but is a complex package manager. At least for me, it doesn't seem more complex than docker ecosystem.
I personally use nix to take care of downloading compatible dependencies in isolation for me. And the rest of the code is really, just basic script shell or Makefile too.
I also could add a fancy
mergeShells
function I have written in nix to support a docker-compose-like composition ofnix-shell
files. But you could go a very long way with nix before you even want to do something like this.