Remote deployment tips for ARM64 host and AMD64 target?


I’m experimenting with running NixOS on some machines in my home lab, and want to be able to work on the configurations for my machines on my Macbook, and deploy them to the machines remotely.

I’ve tried out a couple methods for doing this, but am running into issues because the Macbook where I’m running the deployment is an ARM64 M1 Machine while the target machine for the build is AMD64.

Here’s what I’ve tried so far:

Colmena, with both the build-on-target option and native NixOS distributed builds. Neither of these seem to work because the configuration files are getting evaluated locally before any build starts. This seems to get hung up on some of the imports in my config, like Arion.

Running a NixOS vm, and using nixos-rebuild with --target-host and --build-host set to the target machine. This seems to actually evaluate and build, but fails at the end due to a binary format error - pretty sure that’s also due to the CPU architecture mismatch.

Are there any recommendations or best practices that the community has for this type of deployment?
I think that I could possibly get it to work if I ran an emulated AMD64 NixOS vm on the Mac, but if there are any better options, I’d be thankful for any suggestions.

1 Like

i used:

    # cross-compilation
    boot.binfmt.emulatedSystems = [ "aarch64-linux" ];

ref: Cross-platform Compilation | NixOS & Flakes Book

Which would be for ARM Linux.

For AMD64 Linux you need "x86_64-linux" IIRC.