Creating a bootable and modifiable QEMU image

I have setup a simple host build using NixOS using qemu via virt-manager. I am now working on setting up a guest NixOS which will be where I actually do my work. I am using flakes and home manager for this VM.

I started my journey trying using nixos-generators, which has an option for qcow2 files. However, when I tried do to this I got a size error. I tried to use the --disk-size flag it told me there is no such flag and I didn’t see the flag/option when I ran nixos-generate --help

I tried using the vm option as well as iso and install-iso. With the iso and install-iso option, it would boot and it seemed like it had the elements of my flake/configuration.nix, but I didn’t see a way to “install”. When I looked in documentation I couldn’t find anything like “copy the running config” or “make permenant” or “install with these settings”. I was expecting something like the official gui builder using my configuration.

I actually couldn’t even find the local version of my flake or configuration on either of these options. It had my graphical desktop, default password, etc… but how? I don’t know!

I then found this tutorial from Tarn Barford, which I was able to follow. I wanted to set it up through virt-manager, which required copying the output result/vm to /var/lib/libvirt/images and setting it to EFI bios. This image would boot and it seemed to have persistence between boots.

Unfortunately, I don’t see how to make updates or change to my flake.nix, configuration.nix. With my host doing it “normal” I have all my configuration in /etc/nixos. This is the first time I’ve built with a flake, so I am not sure if I am missing something because of flakes or because of it being a VM.

I would assume I could just edit and rebuild within the VM, but do I need to always rebuild from the host and make a new VM or something else?

If I do something like sudo find / -type f -name "flake.nix" I only see entries in the /nix/store?

Also, Tarn’s guide instructs you to copy the output cqow from the result, which is also in the nix store. How do I clear that out so it’s not just taking up space after the build?