Cross Build x86_64-ami on aarch64 using nixos-generators

It works; you just have to install qemu binfmt emulation on your distro, and then you have to add the necessary paths to extra-sandbox-paths in nix.conf.

Beware that qemu binfmt emulation is extremely slow. The alternative is cross-compilation, but it doesn’t look like nixos-generators is well setup for that. Plus nixpkgs is barely cached for cross-compilation so you’d end up compiling basically all of nixos yourself, and it’s not uncommon for things to simply fail to cross compile.

Point being, the options for building for another platform aren’t great. Frankly, I think it’s better with Nix than it is with anything else, but it’s still rough. My advice is to enable qemu binfmt emulation via your distro, and possibly configure specific packages for cross compilation if you find you need it (e.g. the kernel would be a great candidate if you need to patch it)