based on https://astrid.tech/2022/09/22/0/nixos-gpu-vfio/
This commit is contained in:
parent
be3c76801e
commit
baa2417bfe
|
@ -4,8 +4,11 @@
|
||||||
imports =
|
imports =
|
||||||
[
|
[
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
./vfio.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
vfio.enable = true;
|
||||||
|
|
||||||
# Bootloader
|
# Bootloader
|
||||||
boot = {
|
boot = {
|
||||||
loader = {
|
loader = {
|
||||||
|
|
37
nix/london/vfio.nix
Normal file
37
nix/london/vfio.nix
Normal 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;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue