This commit is contained in:
joygnu 2024-06-18 22:33:31 +02:00
parent 471adbf036
commit ae5b60a72c
3 changed files with 56 additions and 1 deletions

View file

@ -3,7 +3,7 @@
./fonts
./yazi
./sound
./vm
# ./vm
./retro
./packages
./misc

54
modules/gpu/default.nix Normal file
View file

@ -0,0 +1,54 @@
{ pkgs, config, ... }:
let
# Change this to your username.
user = "joy";
# Change this to match your system's CPU.
platform = "amd";
# Change this to specify the IOMMU ids you wrote down earlier.
vfioIds = [ "10de:249c" "10de:228b" ];
in {
# Configure kernel options to make sure IOMMU & KVM support is on.
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}";
};
# Add a file for looking-glass to use later. This will allow for viewing the guest VM's screen in a
# performant way.
systemd.tmpfiles.rules = [
"f /dev/shm/looking-glass 0660 ${user} qemu-libvirtd -"
];
# Add virt-manager and looking-glass to use later.
environment.systemPackages = with pkgs; [
virt-manager
looking-glass-client
];
# Enable virtualisation programs. These will be used by virt-manager to run your VM.
virtualisation = {
libvirtd = {
enable = true;
extraConfig = ''
user="${user}"
'';
# Don't start any VMs automatically on boot.
onBoot = "ignore";
# Stop all running VMs on shutdown.
onShutdown = "shutdown";
qemu = {
package = pkgs.qemu_kvm;
ovmf = enabled;
verbatimConfig = ''
namespaces = []
user = "+${builtins.toString config.users.users.${user}.uid}"
'';
};
};
};
users.users.${user}.extraGroups = [ "qemu-libvirtd" "libvirtd" "disk" ];
}

View file

@ -57,6 +57,7 @@
gnome.gnome-calculator
gnome.gnome-disk-utility
#random utils
pciutils
cliphist
wl-clipboard
git