feat: add virt manager

This commit is contained in:
HerozDotExe 2026-02-26 15:11:33 +01:00
parent 906cb30ef2
commit 0ad2fe19e8
3 changed files with 43 additions and 1 deletions

View file

@ -122,7 +122,10 @@
users.users.heroz = { users.users.heroz = {
shell = pkgs.nushell; shell = pkgs.nushell;
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user. extraGroups = [
"wheel"
"libvirtd"
]; # Enable sudo for the user.
packages = with pkgs; [ packages = with pkgs; [
gnomeExtensions.blur-my-shell gnomeExtensions.blur-my-shell
gnomeExtensions.appindicator gnomeExtensions.appindicator
@ -137,6 +140,10 @@
]; ];
}; };
virtualisation.libvirtd.enable = true;
boot.kernelModules = [ "kvm-intel" ];
programs.virt-manager.enable = true;
# List packages installed in system profile. # List packages installed in system profile.
# You can use https://search.nixos.org/ to find more packages (and options). # You can use https://search.nixos.org/ to find more packages (and options).
# environment.systemPackages = with pkgs; [ # environment.systemPackages = with pkgs; [
@ -162,6 +169,7 @@
# networking.firewall.allowedUDPPorts = [ ... ]; # networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether. # Or disable the firewall altogether.
# networking.firewall.enable = false; # networking.firewall.enable = false;
networking.firewall.trustedInterfaces = [ "virbr0" ];
# Copy the NixOS configuration file and link it from the resulting system # Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you # (/run/current-system/configuration.nix). This is useful in case you

5
virbr0.xml Normal file
View file

@ -0,0 +1,5 @@
<network>
<name>virbr0</name>
<forward mode='bridge'/>
<bridge name='virbr0'/>
</network>

29
vm-bridge-networking.md Normal file
View file

@ -0,0 +1,29 @@
# Bridge networking
Create a XML file called virbr0.xml with the definition of the bridge interface
```xml
<network>
<name>virbr0</name>
<forward mode='bridge'/>
<bridge name='virbr0'/>
</network>
```
Add and enable bridge interface
```sh
virsh net-define virbr0.xml
virsh net-start virbr0
ip link add virbr0 type bridge
ip address ad dev virbr0 10.25.0.1/24
ip link set dev virbr0 up
```
Add a new network device to the vm :
```xml
<interface type='bridge'>
<mac address='52:54:00:12:34:56'/>
<source bridge='virbr0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
```