Build a bare bones bootable nixos qcow2 image suitable for running with libvirt/qemu/kvm.
nix-build '<nixpkgs/nixos>' -A config.system.build.qcow2 --arg configuration "{ imports = [ ./build-qcow2.nix ]; }"
Should create a results
directory that symlinks to a qcow2 image in the store.
I basically copied this from the openstack image in nixpkgs because I don't know a better way.
Update:
Thanks to @d-goldin I've just learnt I can start a VM using just:
nix-build '<nixpkgs/nixos>' -A vm -I nixos-config=./machine-config.nix build-vm
./result/bin/run-nixos-vm
Which is pretty neat, and I guess pretty common.
What is up with the weird formatting in
machine-config.nix
?