Error building x86 binary from m1 Mac via remote builder

I’m on an m1 mac and would like to compile for x86_64-linux on a (x86) remote builder. Any ideas how to do this?

I tried adapting a “hello world” example here but it fails

$ nix build --impure   --expr '(with import <nixpkgs> { system = "x86_64-linux"; }; runCommand "foo" {} "uname > $out")'   --builders 'ssh://nix-builder x86_64-linux'
error: a 'x86_64-linux' with features {} is required to build '/nix/store/a08s5qrl1hsrcyblawv0cdgqphpvy7q8-foo.drv', but I am a 'aarch64-darwin' with features {benchmark, big-parallel, nixos-test}

I’m on nix version 2.11.1 and MacOs 13.0.1 (22A400).

Remember that it’s the daemon that accesses the remote machine, so you have to ensure that the local root user can SSH into it without getting e.g. prompted about the known_hosts thing or problems with access keys.