vfio fuckery
All checks were successful
Lint / lint (push) Successful in 26s

based on https://astrid.tech/2022/09/22/0/nixos-gpu-vfio/
This commit is contained in:
Gabriel Simmer 2023-11-11 17:11:44 +00:00
parent be3c76801e
commit baa2417bfe
Signed by: arch
SSH key fingerprint: SHA256:m3OEcdtrnBpMX+2BDGh/byv3hrCekCLzDYMdvGEKPPQ
2 changed files with 40 additions and 0 deletions

View file

@ -4,8 +4,11 @@
imports =
[
./hardware-configuration.nix
./vfio.nix
];
vfio.enable = true;
# Bootloader
boot = {
loader = {

37
nix/london/vfio.nix Normal file
View file

@ -0,0 +1,37 @@
let
# RTX 3070 Ti
gpuIDs = [
"10de:1b81" # Graphics
"10de:10f0" # Audio
];
in { pkgs, lib, config, ... }: {
options.vfio.enable = with lib;
mkEnableOption "Configure the machine for VFIO";
config = let cfg = config.vfio;
in {
boot = {
initrd.kernelModules = [
"vfio_pci"
"vfio"
"vfio_iommu_type1"
"nvidia"
"nvidia_modeset"
"nvidia_uvm"
"nvidia_drm"
];
kernelParams = [
# enable IOMMU
"amd_iommu=on"
"pcie_acs_override=downstream,multifunction"
] ++ lib.optional cfg.enable
# isolate the GPU
("vfio-pci.ids=" + lib.concatStringsSep "," gpuIDs);
};
hardware.opengl.enable = true;
virtualisation.spiceUSBRedirection.enable = true;
};
}