Cross build nixOS iso on aarch64-darwin -> x86_64-linux

Got it to work. A few things were needed.

  1. the package in the flake should be aarch64-darwin but the actual nixOSsystem should be “x86_64-linux”.
  2. GitHub - cpick/nix-rosetta-builder setup
  3. call nix build without --system "x86_64-linux" and with --option substitute false some drvs were failing: warning: error: unable to download 'https://cache.nixos.org/ssvqaik8k1b7hhbjc4ja0p1vxsrxjx5l.narinfo': Could not resolve hostname (6); retrying in 281 ms (this could also be because of my special dns setup though)
  4. nix.settings.builders-use-substitutes = lib.mkForce false;
  5. nix build --verbose --option substitute false
{
  description = "Minimal NixOS installation media";
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
  outputs = {
    self,
    nixpkgs,
  }: {
    #1:
    packages.aarch64-darwin = rec {
      default = headnode.config.system.build.isoImage;

      headnode = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ({
              modulesPath,
              lib,
              ...
            }:{
              imports = [
                (modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix")
              ];

              isoImage = {
                makeEfiBootable = true;
                makeUsbBootable = true;
                squashfsCompression = "zstd -Xcompression-level 6"; #way faster build time
              };
            })
        ];
      };
    };
  };
}