`nixos-rebuild (boot|switch) ...` attempt build on host rather than required system

I am trying to remotely build and re-configure an x86_64-linux system from an aarch64-darwin host.

The host has configured remote builders as such:

# nix config show
...
builders = ssh://bldr aarch64-linux; ssh://bldr x86_64-linux; ssh://bldr-majestic aarch64-linux; ssh://bldr-majestic x86_64-linux;
...

However, attempts to use nixos-rebuild boot|switch ... result in a platform mismatch:

# nixos-rebuild boot \
--log-format internal-json \
--verbose --flake .#vainglory --target-host "vainglory" \
--max-jobs 0 \
|& nom --json
...
subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command flakes', 'build', '--print-out-paths', '.#nixosConfigurations."vainglory".config.system.build.toplevel', '--no-link', '-v', '--max-jobs', '0', '--log-format', 'internal-json']' returned non-zero exit status 1.
┏━ 161 Errors:
 ⋮
┃        Reason: local builds are disabled (max-jobs = 0)
┃        Hint: set 'max-jobs' to a non-zero value to enable local builds, or configure remote builders via 'builders'
┃        Reason: platform mismatch
┃        Required system: 'x86_64-linux'
┃        Current system: 'aarch64-darwin'
┃ error: Cannot build '/nix/store/kg0pdbqaxlac7nmgv1wr31484b1bjzy0-X-Restart-Triggers-dhcpcd.drv'.
┃        Reason: local builds are disabled (max-jobs = 0)
┃        Hint: set 'max-jobs' to a non-zero value to enable local builds, or configure remote builders via 'builders'
┃        Reason: platform mismatch
┃        Required system: 'x86_64-linux'
┃        Current system: 'aarch64-darwin'
┃ error: Cannot build '/nix/store/xdsa8lg8j3m4r0rmw7dhkkwlihxjlbyg-NetworkManager.conf.drv'.
┃        Reason: local builds are disabled (max-jobs = 0)
┃        Hint: set 'max-jobs' to a non-zero value to enable local builds, or configure remote builders via 'builders'
┃        Reason: platform mismatch
┃        Required system: 'x86_64-linux'
┃        Current system: 'aarch64-darwin'

Not quite sure what’s going on here. It’s worked in past without issue.

My issue was due to typo in /var/root/.ssh/config which caused ssh to fail.

It was discovered as part of: sudo nix store info --store ssh://bldr

After fixing typo in ssh config for root user, remote re-configuration is working again.


edit (2026-06-20): another weird issue I had to resolve was related to ssh and this error:

Received disconnect from <ip> port 2222:2: too many authentication failures

If you have too many ssh keys loaded in identity agent, you may hit this arbitrary authentication limit. You can confirm with ssh -v ...:

# ssh -v bldr
...
debug1: get_agent_identities: agent returned 8 keys
debug1: Will attempt key: ... agent
debug1: Will attempt key:  ... agent
debug1: Will attempt key: ... agent
debug1: Will attempt key: ... agent
debug1: Will attempt key: ... agent
debug1: Will attempt key: ... agent
debug1: Will attempt key: ... agent
debug1: Will attempt key: ... agent
debug1: Will attempt key: /var/root/.ssh/id_ed25519 ... explicit
debug1: Offering public key: ... agent
debug1: Authentications that can continue: publickey
debug1: Offering public key:  ... agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: ... agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: ... agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: ... agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: ... agent
Received disconnect from <ip> port 2222:2: too many authentication failures

I fixed this by adding the following to ssh config [1]:

# sudo vim /var/root/.ssh/config
Host bldr
  ...
  IdentitiesOnly yes
  IdentityAgent  no
  IdentityFile   /var/root/.ssh/id_ed25519

edit (2026-06-20): if you decide to transfer the builders configuration from a string to a file, I ran into an issue where nixos-rebuild would completely ignore my builders.

# nix config show | grep builder
builders = @/etc/nix/machines
# cat /etc/nix/machines
ssh-ng://bldr           aarch64-linux,x86_64-linux /var/root/.ssh/id_ed25519 8 2

This was due to not defining the capabilities or features for each remote builder. I fixed it by adding them manually:

# ssh bldr "nix config show | grep system-features"
system-features = benchmark big-parallel gccarch-armv8-a kvm nixos-test

Then adding only the features I need, separating them with , (comma):

# vim /etc/nix/machines
ssh-ng://bldr           aarch64-linux,x86_64-linux /var/root/.ssh/id_ed25519 8 2 benchmark,big-parallel,gccarch-armv8-a

[1] https://stackoverflow.com/a/75890388