Last active
November 9, 2024 17:28
-
-
Save jchv/b0e4b39679e450536a17cc6a5d69169a to your computer and use it in GitHub Desktop.
Nix configuration for VGA passthrough
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, lib, ... }: | |
{ | |
# IOMMU configuration | |
boot.kernelParams = [ "amd_iommu=on" "pcie_aspm=off" ]; | |
boot.kernelModules = [ "kvm-amd" "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" ]; | |
boot.extraModprobeConfig = '' | |
options vfio-pci ids=10de:13c2,10de:0fbb | |
options kvm ignore_msrs=1 | |
''; | |
boot.postBootCommands = '' | |
# Enable VFIO on secondary GPU | |
for DEV in "0000:0b:00.0" "0000:0b:00.1"; do | |
echo "vfio-pci" > /sys/bus/pci/devices/$DEV/driver_override | |
done | |
modprobe -i vfio-pci | |
# Setup Looking Glass shared memory object | |
touch /dev/shm/looking-glass | |
chown john:kvm /dev/shm/looking-glass | |
chmod 660 /dev/shm/looking-glass | |
''; | |
virtualisation = { | |
libvirtd = { | |
qemuOvmf = true; | |
qemuVerbatimConfig = '' | |
namespaces = [] | |
nographics_allow_host_audio = 1 | |
user = "john" | |
group = "kvm" | |
''; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment