2024-11-06 22:39:23 -05:00
|
|
|
{ config, pkgs, ... }:
|
2024-11-24 16:53:49 -05:00
|
|
|
let
|
|
|
|
commonKernelParams = [
|
|
|
|
# VM/GPU passthrough
|
|
|
|
"amd_iommu=on"
|
|
|
|
"iommu=pt"
|
|
|
|
"nested=1"
|
|
|
|
|
|
|
|
# Virtualization nonsense
|
|
|
|
"transparent_hugepage=never"
|
|
|
|
|
|
|
|
# Isolate devices into IOMMU groups
|
|
|
|
"pcie_acs_override=downstream,multifunction"
|
|
|
|
"pci=routeirq"
|
|
|
|
];
|
|
|
|
in {
|
2024-11-06 22:39:23 -05:00
|
|
|
boot = {
|
2024-11-24 16:53:49 -05:00
|
|
|
# Must be Zen for IOMMU isolation
|
|
|
|
kernelPackages = pkgs.unstable.linuxPackages_zen;
|
2024-11-06 22:39:23 -05:00
|
|
|
kernel.sysctl."vm.max_map_count" = 2147483642;
|
2024-11-24 16:53:49 -05:00
|
|
|
kernelParams = commonKernelParams ++ [ "vfio-pci.ids=10de:1f82,10de:10fa" ];
|
|
|
|
blacklistedKernelModules = [ "pcspkr" ];
|
|
|
|
|
|
|
|
# Needed for GPU passthrough
|
|
|
|
initrd.kernelModules = [
|
|
|
|
"vfio"
|
|
|
|
"vfio_pci"
|
|
|
|
"vfio_iommu_type1"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# Use second GPU on boot
|
|
|
|
specialisation.gputwo.configuration = {
|
|
|
|
boot.kernelParams = commonKernelParams ++ [ "vfio-pci.ids=10de:2504,10de:228e" ];
|
2024-11-06 22:39:23 -05:00
|
|
|
};
|
|
|
|
}
|