Building Docker images with Nix, and a neat discussion of graphing algorithms to decide how to flatten layers: https://grahamc.com/blog/nix-and-layered-docker-images