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.
When I try this, I get
Segmentation fault
. Do you have any thoughts on what's going wrong?nix log
output here: https://gist.github.com/gcr/7857bf5906e20273e156e6b467ef51f7 The command was:nix-build '<nixpkgs/nixos>' -A config.system.build.qcow2 --arg configuration "{imports = [ ./build-qcow2.nix ]; }"
I'm on Debian testingThe log mentions not having access to KVM, but I thought qemu's CPU emulation is a good fallback, so I'm not sure if this is a red herring. Besides, if kvm really was required, wouldn't it be part of the nix store, or is this one of the instances where the host machine's configuration is leaking over?
(i'm trying to learn nix and nixos, but every time i try to run an untested blog post or example like this, it winds up not working on my system... i know it's just my frustration talking, but as a new user, i'm surprised and worried at how brittle these commands turn out to be in practice)