pass nvidia gpu to vm

This commit is contained in:
Kopatz
2025-10-11 15:38:30 +02:00
parent 26f5658e78
commit 7225fdff2e
2 changed files with 19 additions and 7 deletions

View File

@@ -6,9 +6,18 @@ in
{
options.custom.hardware.vfio = {
enable = mkEnableOption "Enables vfio";
stub_pci = mkOption {
type = with lib.types; listOf str;
default = [ ];
description = "List of PCI devices to stub with vfio-pci";
};
};
config = mkIf (cfg.enable && config.virtualisation.libvirtd.enable) {
boot.kernelParams = [ "amd_iommu=on" "iommu=pt" ];
boot = {
kernelModules = [ "vfio" "vfio_iommu_type1" "vfio_pci" ];
kernelParams = [ "amd_iommu=on" "iommu=pt" ] ++ (if cfg.stub_pci != [] then [ "vfio-pci.ids=${concatStringsSep "," cfg.stub_pci}" ] else []);
blacklistedKernelModules = [ "nouveau" "nvidia" "nvidiafb" "nvidia-drm" "nvidia-uvm" "nvidia-modeset" ];
};
};
}