nyx/modules/nixos/virtualisation.nix

59 lines
1.1 KiB
Nix
Raw Normal View History

2024-12-20 13:11:42 +00:00
{
pkgs,
lib,
config,
...
}: let
enableIOMMU = true;
in {
boot = lib.mkIf enableIOMMU {
2024-12-20 13:11:42 +00:00
initrd.kernelModules = lib.mkBefore [
"kvm-amd"
"vfio_pci"
"vfio_iommu_type1"
"vfio"
];
2024-11-16 22:07:01 +00:00
kernelParams = [
"amd_iommu=on"
"amd_iommu=pt"
"kvm.ignore_msrs=1"
"vfio-pci.ids=1002:67df,1002:aaf0"
];
extraModprobeConfig = ''
softdep drm pre: vfio-pci
2024-11-16 22:07:01 +00:00
options kvm_amd nested=1
options kvm ignore_msrs=1 report_ignored_msrs=0
'';
};
2024-11-16 22:07:01 +00:00
hardware.ksm.enable = true;
virtualisation = {
libvirtd = {
enable = true;
onBoot = "ignore";
onShutdown = "shutdown";
qemu = {
package = pkgs.qemu_kvm;
ovmf.enable = true;
};
};
2024-12-20 13:11:42 +00:00
docker = {enable = true;};
};
2024-12-20 13:11:42 +00:00
programs = {virt-manager = {enable = true;};};
2024-10-28 15:59:07 +00:00
2024-12-20 13:11:42 +00:00
users.users.pingu.extraGroups = ["qemu-libvirtd" "libvirtd" "disk" "kvm" "docker"];
environment.systemPackages = with pkgs; [
2024-11-16 22:07:01 +00:00
python3 # scripts, cba to use nix shell all the time
usbutils
pciutils
virt-manager
2024-11-16 22:07:01 +00:00
moonlight-qt # for linux vms
2025-01-01 13:55:38 +00:00
# looking-glass-client # for windows vms :husk:
];
}