Feature Request: Declarative configuration of Virt Manager's networks

Is it possible to extend virtualisation.libvirtd and let users declare their networks there:

virtualisation.libvirtd = {
    enable = true;
    networks = {
        default = {
            network: "192.168.122.0/24";
            autostart: false;
        };
        
        custom = {
            network: "172.16.0.0/24";
            autostart: true;
        };
    };
};

Relevant screenshots:

Thanks. By the way, there’s this project:

Never tried it.

2 Likes

Can confirm that nixvirt lets you add those declaratively. Little fiddly backing into the definitions you need via the XML virtman wants, but it works.

It would be great if the customizations could be done via NixOS’s own virtualisation.libvirtdif in terms of NixOS’s philosophy it’s acceptable.

Is that not exactly what NixVirt lets you do?

I mean I want to do it without using NixVirt, just by using these options.

Maybe one of the options can be used to declare networks, or generate something like this:

<network>
  <name>default</name>
  <uuid>caf114ad-0a11-49b7-a518-520870661205</uuid>
  <forward mode="nat">
    <nat>
      <port start="1024" end="65535"/>
    </nat>
  </forward>
  <bridge name="virbr0" stp="on" delay="0"/>
  <mac address="54:55:00:c2:2c:44"/>
  <ip address="192.168.122.1" netmask="255.255.255.0">
    <dhcp>
      <range start="192.168.122.2" end="192.168.122.254"/>
    </dhcp>
  </ip>
</network>
<!-- ... -->

but I can’t seem to find it.

1 Like