Hi!
I was reading that in order to build docker images for different architectures, there is the “docker buildx” command that uses the moby/buildkit (that’s how I understood, I’m new to this…). I was wondering if this is available on NixOS? I tried with DOCKER_CLI_EXPERIMENTAL which didn’t work and I couldn’t find info for NixOS regarding the buildx command.
Thanks in advance for hints and tips!
Regards
Eike
It’s disabled by default though. To enable it you just need to override the attribute buildxSupport and set it to true. You also need to be on 21.05 or unstable, as the option had not yet been added as of 20.09’s release.
Example:
buildInputs = [
# other stuff
(docker.override(args: { buildxSupport = true; }))
# other stuff
];
I was reading that in order to build docker images for different architectures, there is the “docker buildx” command that uses the moby/buildkit (that’s how I understood, I’m new to this…). I was wondering if this is available on NixOS?
The “nix way” to doing this is to use the pkgsCross target platforms:
$ nix build .#pkgsCross.aarch64-multiplatform.hello
$ file ./result/bin/hello
./result/bin/hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /nix/store/ichh39fkp51jjflzimrl46lnl3266c9y-glibc-aarch64-unknown-linux-gnu-2.32-46/lib/ld-linux-aarch64.so.1, for GNU/Linux 2.6.32, not stripped
Thank you! This can be used to cross-build nix derviations for a different architecture?
I’m not sure I understand - if I paste this nix build .#pkgsCross… into my terminal it doesn’t understand this (don't know what to do with argument). Is there a typo maybe; or does my brain left me somewhere (sorry)?
And for some reason I wasn’t able to lookup the docker-buildx - I’m sorry. Now I can easily find it using nix search. I don’t know why I didn’t find it in the first place…!
@eikek mark jonringer’s response as the solution please. I didn’t see docker-buildx because I haven’t updated my nix search cache since I updated to 21.05.
Thank you both for your help! I think it’s time to read up on flakes, I sadly haven’t so far. I wanted to mark both answers, because they both work for me