{ config, pkgs, ... } let passthrough = pkgs.writeShellScript "pasthrough.sh" '' GUEST_NAME="$1" HOOK_NAME="$2" STATE_NAME="$3" set -e set -x # For the windows 10 VM if[$GUEST_NAME == 'win10']; then # Prepare hook if["$HOOK_NAME/$STATE_NAME" == "prepare/begin"]; then # Remove Hyprland ${pkgs.busybox}/bin/pkill Hyprland # Unbind VTconsoles ${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon0/bind ${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon1/bind # Unbind EFI-Framebuffer ${pkgs.busybox}/bin/echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind # Unload Modules ${pkgs.busybox}/bin/modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia # Unbind the GPU from display driver ${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_0 ${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_1 # Load VFIO Kernel Module ${pkgs.busybox}/bin/modprobe vfio_pci elif["$HOOK_NAME/$STATE_NAME" == "release/end"]; then # Re-Bind GPU to Nvidia Driver (replace the pci addresses with yours) ${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_0 ${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_1 ${pkgs.busybox}/bin/modprobe -r vfio-pci #bind efi ${pkgs.busybox}/bin/echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind # Reload nvidia modules ${pkgs.busybox}/bin/modprobe nvidia_drm ${pkgs.busybox}/bin/modprobe nvidia_modeset ${pkgs.busybox}/bin/modprobe nvidia_uvm ${pkgs.busybox}/bin/modprobe nvidia # Rebind VT consoles ${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon0/bind ${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon1/bind fi fi ''; in { imports = [ ./hardware-configuration.nix ]; virtualization.libvirtd.hooks.qemu = { passthrough = "${passthrough}"; }; networking.hostName = "malachite"; time.timeZone = "America/Los_Angeles"; # Read the Docs before Changing system.stateVersion = "23.05"; # Did you read the comment? };