From 6318113c7682c385411d5862a5f129712f2ed777 Mon Sep 17 00:00:00 2001 From: "Agatha V. Lovelace" Date: Fri, 22 Nov 2024 17:31:21 +0100 Subject: [PATCH] Configure Windows VM --- common/fragments/virt.nix | 39 +++++++++++++++++++++++++++++++++++ hosts/tears/configuration.nix | 4 ++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 common/fragments/virt.nix diff --git a/common/fragments/virt.nix b/common/fragments/virt.nix new file mode 100644 index 0000000..c981e11 --- /dev/null +++ b/common/fragments/virt.nix @@ -0,0 +1,39 @@ +{ pkgs, lib, ... }: +{ + boot = { + initrd.kernelModules = [ + "vfio_pci" + "vfio" + "vfio_iommu_type1" + + "amdgpu" + ]; + + kernelParams = + let + gpuIDs = [ + "1002:67df" # Graphics + "1002:aaf0" # Audio + ]; + in + [ + # enable IOMMU + "amd_iommu=on" + ("vfio-pci.ids=" + lib.concatStringsSep "," gpuIDs) + ]; + }; + + hardware.opengl.enable = true; + virtualisation.spiceUSBRedirection.enable = true; + services.openssh.settings.X11Forwarding = true; + + # Virtualization + virtualisation.libvirtd = { + enable = true; + onBoot = "start"; + onShutdown = "shutdown"; + }; + + programs.virt-manager.enable = true; + users.users.agatha.extraGroups = [ "libvirtd" ]; +} diff --git a/hosts/tears/configuration.nix b/hosts/tears/configuration.nix index 26dc2bd..b3cbcfb 100644 --- a/hosts/tears/configuration.nix +++ b/hosts/tears/configuration.nix @@ -1,8 +1,8 @@ { imports = [ ./hardware-configuration.nix - ../../common/fragments/graphical - ../../common/fragments/yubikey.nix + ../../common/fragments/graphical/barebones.nix + ../../common/fragments/virt.nix ../../common/home_manager/common.nix ];