diff --git a/hosts/common/services/default.nix b/hosts/common/services/default.nix index 848c8bf..630a6b3 100644 --- a/hosts/common/services/default.nix +++ b/hosts/common/services/default.nix @@ -1,6 +1,7 @@ { imports = [ ./vm.nix + ./vfio.nix ./steam.nix ./polkit.nix ./appimage.nix diff --git a/hosts/common/services/vfio.nix b/hosts/common/services/vfio.nix new file mode 100644 index 0000000..c75cf7b --- /dev/null +++ b/hosts/common/services/vfio.nix @@ -0,0 +1,51 @@ +{ config +, lib +, pkgs +, ... +}: +with lib; let + cfg = config.common.services.appimage; +in +{ + options.common.services.vfio.enable = mkEnableOption "enable GPU Passthrough with looking-glass"; + + config = mkIf cfg.enable { + + environment.systemPackages = with pkgs; [ + looking-glass-client + scream + ]; + + boot.initrd.availableKernelModules = [ "vfio-pci" "nvidia" ]; + boot.initrd.preDeviceCommands = '' + DEVS="0000:01:00.0" # Set your GPU here + for DEV in $DEVS; do + echo "vfio-pci" > /sys/bus/pci/devices/$DEV/driver_override + done + modprobe -i vfio-pci + ''; + + boot.kernelPackages = pkgs.linuxPackages_latest; + boot.kernelParams = [ "intel_iommu=on" "pcie_aspm=off" ]; + boot.kernelModules = [ "kvm-intel" ]; #kvm-amd if AMD + boot.blacklistedKernelModules = [ "nouveau" "nvidia" "nvidiafb" "nvidia_drm" ]; + + + + systemd.tmpfiles.rules = [ + "f /dev/shm/scream 0660 nomad qemu-libvirtd -" # your username + "f /dev/shm/looking-glass 0660 nomad qemu-libvirtd -" # your username + ]; + + systemd.user.services.scream-ivshmem = { + enable = true; + description = "Scream IVSHMEM"; + serviceConfig = { + ExecStart = "${pkgs.scream}/bin/scream-ivshmem-pulse /dev/shm/scream"; + Restart = "always"; + }; + wantedBy = [ "multi-user.target" ]; + requires = [ "pulseaudio.service" ]; + }; + }; +} diff --git a/hosts/common/services/vm.nix b/hosts/common/services/vm.nix index 6fb2e12..075bcd4 100644 --- a/hosts/common/services/vm.nix +++ b/hosts/common/services/vm.nix @@ -24,6 +24,7 @@ in win-virtio win-spice adwaita-icon-theme + virtiofsd #bridge-utils ]; diff --git a/hosts/unkown/configuration.nix b/hosts/unkown/configuration.nix index b64dc24..ef75d54 100644 --- a/hosts/unkown/configuration.nix +++ b/hosts/unkown/configuration.nix @@ -17,8 +17,9 @@ common.services.xdgportal.enable = true; # Filemanager common.services.nautilus.enable = true; - # Virtual Box (Virt-Manager) - common.services.vm.enable = false; + # Virtual Box (Virt-Manager) and GPU Passthru. you have to configure hosts/services/vfio.nix for passthrough to work! + common.services.vm.enable = true; + common.services.vfio.enable = false; # AppStores common.services.appimage.enable = true; common.services.steam.enable = true; diff --git a/hosts/unkown/hardware-configuration.nix b/hosts/unkown/hardware-configuration.nix index 6739d23..f3c9e27 100644 --- a/hosts/unkown/hardware-configuration.nix +++ b/hosts/unkown/hardware-configuration.nix @@ -10,7 +10,7 @@ ]; boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" ]; - boot.initrd.kernelModules = [ ]; + boot.initrd.kernelModules = [ "nvidia" ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ];