Since converting all my home devices to NixOS, I now have a plethora of different architectures to manage: aarch64, x86_64, and ppc64le. I would like to compile all my packages on the beefiest server, despite being a different architecture than some of the targets.
There are two main ways of building a package for a different architecture:
- QEMU emulated “native” compilation
Both of these have their drawbacks. QEMU compilation almost always works but can be quite slow and inefficient (albeit still faster than a Raspberry Pi). Cross-compilation is fast but can get hairy. Complex packages such as Firefox are likely to fail to cross-build.
There is a hybrid approach I have successfully used with Debian packages which I would like to try and get working with Nix. Essentially you take the first approach (QEMU full emulation), but selectively replace executables in that chroot with their native/cross-compilation counterpart. Typically replacing GCC alone is enough for a significant speed boost, but replacing bash, perl, etc can also be helpful. Here’s a post from the qemu mailing list describing this strategy.
I don’t expect to have a breakthrough with this strategy anytime soon, but I wonder if anyone has already attempted this with Nix?