Feedback about running Home Assistant using NixVirt declaratively

Hey folks, I’ve started playing with nixos a few weeks ago and in the meantime was planning on moving my home-assistant installation from docker to HAOS as support is much stronger there.

Looking at the wiki I was surprised that there was no declarative howto of running it on a VM, instead both options rely on using nixos to set up libvirt/incus and then installing the VM manually.

I’ve spent a couple days playing with NixVirt and although it was not easy as there’s many silent failures I’ve managed to put up a module that spins the VM declaratively.

It didn’t make my effort easier, but I decided that I didn’t want to use any storage pools or linux bridges, so I had to override many of the default nixvirt template bits to use a macvtap interface and set a scsi controller.

home_assistant.nix

I wanted to gather feedback here on what I could do better here. Maybe this can grow to be part of the tutorial on the wiki. I would probably either ask or try to add some of the necessary changes in NixVirt first though as it could simplify it quite a bit.

1 Like

Hey,

Maybe not quite what you are asking for, but I just wanted to say that I’m not happy with my current setup, running the vm through some libvirt code and linux bridges that I don’t really understand.

I’d be very happy to try your method if you think it is better. Does it set up a service to start the vm on boot etc?

It is, yeah. If you enable autostart the libvirt-guests systemd unit will bring it up. I’ve also configured it to gracefully shutdown on stop as suspending was not working well with USB passthrough.

That’s the same reason I went for macvtap, the Linux bridge not only adds a hop in the way, I don’t like to change the whole system network configuration because of a VM.