51 lines
1.3 KiB
Nix
51 lines
1.3 KiB
Nix
{ config, lib, system, pkgs, ... }:
|
|
{
|
|
boot.kernelModules = [
|
|
"vfio"
|
|
"vfio-pci"
|
|
"vfio_iommu_type1"
|
|
];
|
|
boot.kernelParams = [
|
|
"amd_iommu=on"
|
|
"iommu=pt"
|
|
];
|
|
# Make sure vfio is available inside initrd
|
|
boot.initrd.availableKernelModules = [
|
|
"vfio_pci"
|
|
];
|
|
# Bind by IDs (cleaner via modprobe instead of kernel param)
|
|
boot.extraModprobeConfig = ''
|
|
options vfio-pci ids=10de:1b81,10de:10f0
|
|
'';
|
|
boot.initrd.systemd = {
|
|
enable = true;
|
|
services.initrd-vfio-pci-nvidia = {
|
|
|
|
description = "vfio-pci predevice init";
|
|
wantedBy = [ "initrd.target" ];
|
|
# Match 'preDeviceCommands' by running early
|
|
before = [ "sysroot.mount" ];
|
|
|
|
unitConfig.DefaultDependencies = "no";
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
# Place your original shell commands here
|
|
script = ''
|
|
modprobe vfio-pci
|
|
'';
|
|
}
|
|
# # EARLY and deterministic binding
|
|
# boot.initrd.preDeviceCommands = ''
|
|
# echo 0000:05:00.0 > /sys/bus/pci/drivers/vfio-pci/bind
|
|
# echo 0000:05:00.1 > /sys/bus/pci/drivers/vfio-pci/bind
|
|
# '';
|
|
environment.systemPackages = with pkgs; [
|
|
pciutils
|
|
virtiofsd
|
|
config.virtualisation.libvirtd.qemu.package
|
|
looking-glass-client
|
|
virt-manager
|
|
libguestfs-with-appliance
|
|
];
|
|
users.extraUsers.andreas.extraGroups = [ "libvirtd" ];
|
|
} |