Run NixOS ISO using Apple Virtualization framework (for example UTM)
- local: Download ISO
- local: Mount
hdiutil mount *.iso
- local: Copy kernel and initrd:
cp /Volumes/nixos-minimal-2?/boot/{Image,initrd} .
. - local: Find and copy kernel params:
less /Volumes/nixos-minimal-2?/EFI/boot/grub.cfg
- local: Append
console=hvc0
to params. - UTM: Create a new "drive". 16 GB is comfortable, 64 GB is plenty. Attach to your VM.
- UTM: Attach the ISO.
- UTM: Put kernel, initrd and set kernel params.
- VM: Follow https://nixos.org/manual/nixos/stable/index.html#ch-installation. Partition with "Legacy Boot (MBR)" scheme to be able to use
boot.loader.generationsDir
. Later disable Grub as below: - VM: configuration.nix:
# Switch to true if you want to check the current default kernel params. /boot/grub/grub.cfg will be created.
boot.loader.grub.enable = false;
boot.loader.grub.device = "nodev";
# Creates /boot/default/kernel, /boot/default/initrd and a new subdirectory for each kernel and initrd upgrade under /boot. Makes it easier to copy these to host and simplify kernel params below.
boot.loader.generationsDir.enable = true;
# Recently started producing kernels unbootable by Apple Virtualization, so it's disabled until a fix can be found
# boot.kernelPackages = pkgs.linuxPackages_latest;
services.openssh = {
enable = true;
};
- VM:
nixos-install
- VM: Enable root SSH login in your installation VM
- local: copy new kernel and initrd from your new VM:
scp root@vm:"/mnt/boot/nixos-{kernel,initrd}" .
- VM:
poweroff
the installer - UTM: Use kernel, initrd and kernel params in VM's settings:
console=hvc0 boot.shell_on_fail init=/boot/default/init loglevel=4
- UTM: Boot your VM
@a-h recently
boot.kernelPackages = pkgs.linuxPackages_latest;
started producing kernels that don't work with Apple Virtualization framework. Reverting to the default kernel by removing this line works. I'm not sure what might be causing this, as until recently 5.19 Linux kernels were fine. I suspect something could have been changed in the way kernel Nix package is built, but I haven't got time to properly investigate.