Tried this out on the day it was released, and it's been awesome so far.
Usually structuring images would take a lot of manual tweaking to get the layers just right, but with this I just adjust the number of layers and watch magic happen :)
Average push size down from over 300MB to 15MB for an image of over 1.4GB, and takes like 15 lines of code to write.
What I like about Nix is that this kind of functionality can be integrated into the Nixpkgs package set, as a function over packages.
It's just as easy as writing a machine image or an virtual machine network test, because Nixpkgs has functions you can use for those as well.
I really like this. I think it is a great compromise between the limitations of docker and everything packaged in one file while taking advantage of nix. I'm curious about one other optimization that could be made.
You could instead look at the dependency graph of several nix docker builds and increase the cache reuse even more from that.
This approach is already optimal for up to around 40 or 120 packages, depending on whether you want to support old Docker versions.
"Where before you wouldn’t bother trying to have your application and database images share layers, with Nix the layer sharing is completely automatic."
Great post on the issues of Docker's linear layering method (which a tweet[1] by the author of the post also explains well independently of computers) and how to improve on it with Nix.
The "old" way of building Docker images with Nix also provided some of these benefits, but for quick builds often ended up being slower due to the dependency on qemu. This is an awesome improvement on that!
I'd recommend people building & deploying a lot of Docker images (especially in languages with many dependencies on native libraries and such, which can be tricky to get right but which Nix mostly just handles for you) to see if building images with Nix could improve your workflow!
Neat. It seems like Nix could become the preferred way to build Docker images, if it's made a bit more user friendly. It's hard to beat the simplicity of
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y mysql php