diff --git a/host/rune/default.nix b/host/rune/default.nix index 4376e64..cf28199 100644 --- a/host/rune/default.nix +++ b/host/rune/default.nix @@ -16,8 +16,9 @@ # Modules ./modules/fish - ./modules/steam ./modules/gnome + ./modules/steam + ./modules/vm ]; ## NETWORKING ## diff --git a/host/rune/home/default.nix b/host/rune/home/default.nix index 8e943e9..1bf29d4 100644 --- a/host/rune/home/default.nix +++ b/host/rune/home/default.nix @@ -14,7 +14,7 @@ # Modules ../modules/gnome/home.nix - ../modules/fish + ../modules/vm/home.nix ]; # Enables app shorcuts diff --git a/host/rune/modules/gnome/home.nix b/host/rune/modules/gnome/home.nix index c696e1c..ea1b18d 100644 --- a/host/rune/modules/gnome/home.nix +++ b/host/rune/modules/gnome/home.nix @@ -50,6 +50,7 @@ favorite-apps = [ "org.gnome.Nautilus.desktop" "org.wezfurlong.wezterm.desktop" + "win11.desktop" "zen.desktop" "spotify.desktop" "vesktop.desktop" diff --git a/host/rune/modules/vm/default.nix b/host/rune/modules/vm/default.nix new file mode 100644 index 0000000..66f14e8 --- /dev/null +++ b/host/rune/modules/vm/default.nix @@ -0,0 +1,56 @@ +{ + config, + pkgs, + admin, + ... +}: +{ + + # Enable dconf (System Management Tool) + programs.dconf.enable = true; + + # Add user to libvirtd group + users.users.${admin}.extraGroups = [ "libvirtd" ]; + + # Install necessary packages + environment.systemPackages = with pkgs; [ + qemu + qemu_kvm + spice + spice-gtk + spice-protocol + virtiofsd + win-spice + win-virtio + ]; + + networking.firewall = { + allowedTCPPortRanges = [ + # spice + { + from = 5900; + to = 5999; + } + ]; + allowedTCPPorts = [ + # libvirt + 16509 + ]; + }; + + programs.virt-manager.enable = true; + virtualisation = { + libvirtd = { + enable = true; + qemu = { + runAsRoot = true; + swtpm.enable = true; + ovmf.enable = true; + ovmf.packages = with pkgs; [ OVMFFull.fd ]; + vhostUserPackages = with pkgs; [ virtiofsd ]; + }; + }; + spiceUSBRedirection.enable = true; + }; + services.spice-vdagentd.enable = true; +} diff --git a/host/rune/modules/vm/home.nix b/host/rune/modules/vm/home.nix new file mode 100644 index 0000000..5f66ff4 --- /dev/null +++ b/host/rune/modules/vm/home.nix @@ -0,0 +1,34 @@ +{ + config, + pkgs, + ... +}: +{ + dconf.settings = { + "org/virt-manager/virt-manager/connections" = { + autoconnect = [ + "qemu:///session" + "qemu:///system" + ]; + uris = [ + "qemu:///session" + "qemu:///system" + ]; + }; + }; + + xdg.desktopEntries = { + win11 = { + name = "Windows 11"; + comment = "Windows 11 VM"; + exec = "virt-manager --connect qemu:///system --show-domain-console win11-sys"; + icon = "windows95"; + type = "Application"; + terminal = false; + categories = [ + "System" + "Application" + ]; + }; + }; +}