From 2b80993ef7e78a3553ee960489e5836dd6827a8e Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Sat, 15 Feb 2025 10:41:27 -0700 Subject: [PATCH] pci passthrough --- nix/home-server.nix | 1 + nix/modules/pci-passthrough.nix | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 nix/modules/pci-passthrough.nix diff --git a/nix/home-server.nix b/nix/home-server.nix index 565e170..128262a 100644 --- a/nix/home-server.nix +++ b/nix/home-server.nix @@ -6,6 +6,7 @@ [ ./modules/k3s.nix + ./modules/pci-passthrough.nix ]; # Bootloader. diff --git a/nix/modules/pci-passthrough.nix b/nix/modules/pci-passthrough.nix new file mode 100644 index 0000000..f1de1a2 --- /dev/null +++ b/nix/modules/pci-passthrough.nix @@ -0,0 +1,26 @@ +let + gpuIDs = [ + "10de:2704" # Graphics + "10de:22bb" # Audio + ]; +in { pkgs, lib, config, ... }: { + boot = { + initrd.kernelModules = [ + "vfio_pci" + "vfio" + "vfio_iommu_type1" + "vfio_virqfd" + + # "nvidia" + # "nvidia_modeset" + # "nvidia_uvm" + # "nvidia_drm" + ]; + + kernelParams = [ + "intel_iommu=on" + ] ++ lib.optional cfg.enable + # isolate the GPU + ("vfio-pci.ids=" + lib.concatStringsSep "," gpuIDs); + }; +} \ No newline at end of file