VFIO - GPU Passthrough and looking-glass

This commit is contained in:
nomadics9 2024-10-11 20:24:45 +03:00
parent fed8eb6e7c
commit 86837d211a
5 changed files with 57 additions and 3 deletions

View file

@ -1,6 +1,7 @@
{
imports = [
./vm.nix
./vfio.nix
./steam.nix
./polkit.nix
./appimage.nix

View file

@ -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" ];
};
};
}

View file

@ -24,6 +24,7 @@ in
win-virtio
win-spice
adwaita-icon-theme
virtiofsd
#bridge-utils
];

View file

@ -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;

View file

@ -10,7 +10,7 @@
];
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" ];
boot.initrd.kernelModules = [ ];
boot.initrd.kernelModules = [ "nvidia" ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];