diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index a6fddc0..8c1c6d6 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -3,5 +3,6 @@ ./catppuccin.nix ./games/default.nix ./services/default.nix + ./virtualisation.nix ]; } diff --git a/modules/nixos/virtualisation.nix b/modules/nixos/virtualisation.nix new file mode 100644 index 0000000..f937eb3 --- /dev/null +++ b/modules/nixos/virtualisation.nix @@ -0,0 +1,34 @@ +{ pkgs, lib, config, ... }: +let + platform = "amd"; + vfioIds = [ "" "" ]; +in { + boot = { + kernelModules = [ "kvm-${platform}" "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" ]; + kernelParams = [ "${platform}_iommu=on" "${platform}_iommu=pt" "kvm.ignore_msrs=1" ]; + extraModprobeConfig = "options vfio-pci ids=${builtins.concatStringsSep "," vfioIds}"; + }; + + virtualisation = { + libvirtd = { + enable = true; + onBoot = "ignore"; + onShutdown = "shutdown"; + }; + + qemu = { + package = pkgs.qemu_kvm; + ovmf.enable = true; + }; + + docker = { + enable = true; + }; + }; + + environment.systemPackages = with pkgs; [ + virt-manager + ]; + + +}