Remote building not working

I am trying to deploy my nixos configuration to a remote x86 machine from my aarch64 laptop.

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

  outputs =
    {
      nixpkgs,
      ...
    }:
    {
      nixosConfigurations.rebuild= nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix
          ./hardware-configuration.nix
        ];
      };
    };
}

However when I deploy using:

nixos-rebuild switch \
  --flake ".#rebuild" \
  --build-host james@192.168.1.253 \
  --target-host james@192.168.1.253 \
  --use-remote-sudo

I get the following error:

error: a 'x86_64-linux' with features {} is required to build '/nix/store/1gdwjhp6b5wv3d6s9333jp8i59w4prkb-nixos-rebuild.drv', but I am a 'aarch64-linux' with features {benchmark, big-parallel, gccarch-armv8-a, kvm, nixos-test}

This is obviously saying that my arm64 cpu doesn’t know how to build x86 packages however this doesn’t make sense as I have told it to offload the build (via --build-host above).

I must be missing something. Does anybody know what is going on here?

boot.binfmt.emulatedSystems = [ "x86_64-linux" ];

You could also try using the --fast flag which doesn’t rebuild nixos-rebuild before building your system.

@con-f-use I think this would build the packages locally and then copy them. I’m trying to perform a remote build so that it builds the packages on the remote system using it’s own nix store.

Please note that on macOS you also need to provide the --fast flag.

Does that flag help?

Yes --fast worked! Thank you :slight_smile: