This is not an accurate explanation. 1) It has nothing to do with flakes. 2) The only part that’s baked into Nix is the ability to set the extra-platforms
setting so that it will attempt to do builds for different platforms.
The way it actually works is quite simple though. On NixOS, you just set boot.binfmt.emulatedSystems = ["aarch64-linux"];
. This setting enables your machine to transparently run binaries built for aarch64. It does this with binfmt
(see: man binformat.d
), so that when an aarch64 binary is executed, the associated emulator is automatically launched to run it. boot.binfmt.emulatedSystems
also configures the extra-platforms
Nix setting so that Nix will attempt to build as an aarch64-system despite not natively supporting it, and then the binfmt
magically makes it work.
TL;DR: All you have to do is add boot.binfmt.emulatedSystems = ["aarch64-linux"];
to your NixOS config; no need for flakes.