Error when running nixos-generate

I’m trying to build a hyperv vm with nixos-generate with the following command from my macbook. Command works and builds ok when I run it from within nixos.

nixos-generate -f hyperv --flake .#my-machine

But getting the following error.

**error:** a '**x86_64-linux**' with features {} is required to build '**/nix/store/kv45j0ldjyciw9dm8nh318c03wfmly9z-X-Restart-Triggers-sshd.drv**', but I am a '**x86_64-darwin**' with features {**apple-virt, benchmark, big-parallel, nixos-test**}

It would be nice to be able to create my nixos machines from my macbook. Is there a workaround to make this work?

that looks great thanks for sharing this

Hey @wamserma actually took me a long time to get back to this one.

Anyway that looks great and has led me down the path of the various methods for running linux-builders on macos.

IE here Build and Deploy Linux Systems from macOS

Essentially my system is fairly simple so am just wanting to add the linux builder to essentially wrap this flake so that the linux builder ephemerally runs the build locally.

It looks like it might be possible but may be pushing my flake knowledge to the max. How would I go about this?

{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    nixos-generators = {
      url = "github:nix-community/nixos-generators";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = { self, nixpkgs, nixos-generators, ... }: {
    packages.x86_64-linux = {
      qemu = nixos-generators.nixosGenerate {
        system = "x86_64-linux";
        format = "qemu";
      };
    };
  };
}