37 lines
959 B
Nix
37 lines
959 B
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.preDeviceCommands = ''
|
|
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" ];
|
|
} |