I have a flake like the below that I have created after reading this Tweag blog post and consulting the macos-builder flake, and the nixos-vm-on-macos flake.
{
description = ''
Based on https://github.com/YorikSar/nixos-vm-on-macos/blob/24025c73634e580045744c169be1be167b12fe50/flake.nix
'';
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-22.05;
#inputs.flake-utils.url = github:numtide/flake-utils;
outputs = { self, nixpkgs, flake-utils }: {
nixosModules = {
vm = { modulesPath, ... }: {
imports = [
"${modulesPath}/virtualisation/qemu-vm.nix"
];
system.stateVersion = "22.05";
# Configure networking
networking.useDHCP = false;
networking.interfaces.eth0.useDHCP = true;
# Create user "test"
services.getty.autologinUser = "test";
users.users.test.isNormalUser = true;
# Enable passwordless ‘sudo’ for the "test" user
users.users.test.extraGroups = ["wheel"];
security.sudo.wheelNeedsPassword = false;
# Make it output to the terminal instead of separate window
virtualisation.graphics = false;
programs.nbd.enable = true;
};
};
nixosConfigurations.darwinVM = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
self.nixosModules.vm
{
virtualisation.host.pkgs = nixpkgs.legacyPackages.aarch64-darwin;
}
];
};
packages.aarch64-darwin.darwinVM = self.nixosConfigurations.darwinVM.config.system.build.vm;
packages.aarch64-darwin.default = self.packages.aarch64-darwin.darwinVM;
};
}
When I execute nix run #.darwinVM
, I get The option virtualisation.host does not exist.
. What am I missing?