I was reading this article here: https://mitchellh.com/writing/nix-with-dockerfiles

...and decided to try and see how big an image 'just' containing htop would be - and it's actually massive. Honestly, Alpine + Musl still looks to be the better bet for this - it's hardly smaller...

I wonder if there is a musl/static Nix config? Like, use musl libc, prefer/compile only static binaries... In my own build, I could obviously also use UPX. But from a size perspective, I don't see the benefit of Nix over Alpine. o.o

Reply to this note

Please Login to reply.

Discussion

Aren't nixops builds super stripped down? They're supposed to be hermetic and not contain a single extra unnecessary dependency, binary, or library

Not a nix fanboy or nothing, but I've seen it do some seriously wild stuff

Yes, that is correct. Unfortunately, by default, Nix uses dynamic libraries and their FULL package (man pages and everything included).

I later learned of pkgsStatic; an overlay in nixpkgs that focuses entirely on static things. With that, and then using nix-store -qa $folder, I saw MUCH less garbage inbetween. So, pkgsStatic (or perhaps pkgsMusl, also a thing) is a good solution for using a multi stage docker container with Nix - this way, it only returns what you really and actually need.

But, I am also still learning... ^^'

Epic!