Since nix stores everything in /nix/store you could just expose the /nix as readonly volume with docker. This would make the docker images tiny. The rest would just be symlinks. Wondering if anyone has tried this approach?
I understand that it exposes all packages. Which means that no sensitive information should be stored in the /nix/store.
I remember setting up something like that before. Using tianon/true as the smallest available docker image, you can mount the nix store and some local folder an voilà :-).
If you only want one application, this is enough. I remember stumbling on setting up a nixos configuration because you need to adapt the init scripts that start systemd and configure /etc. In particular, systemd inside docker is… well, not easy to say the least.
So this leads me to a new idea: You could hook into nix-shell logic to get a working environment within docker, without needing to fiddle with all the nixos stuff.
I am interested in any developments of lightweight nix+docker containers, as we are contemplating using them for running student code in isolation for INGInious [1][2].
In particular, getting the right $PATH, shell and network access is required.