Compare commits

..

No commits in common. "eb87bbcd16e26f44a83cb1a7e9af56164cad068a" and "16ae89045854dc506c72f6253a2e9384cf247452" have entirely different histories.

2 changed files with 45 additions and 63 deletions

View file

@ -1,15 +1,11 @@
{ config, pkgs, lib, ... }:
{ config, pkgs, ... }:
let
passthrough = pkgs.writeShellApplication {
name = "pasthrough.sh";
runtimeInputs = lib.attrVals [ "coreutils" "kmod" "libvirtd" "procps" ] pkgs;
text = ''
passthrough = pkgs.writeShellScript "pasthrough.sh" ''
GUEST_NAME="$1"
HOOK_NAME="$2"
STATE_NAME="$3"
echo 19>/home/stitchynyan/startlogfile
BASH_XTRACEFD=19
set -e
set -x
# For the windows 10 VM
@ -19,50 +15,45 @@ let
if [[ "$HOOK_NAME/$STATE_NAME" == "prepare/begin" ]]; then
# Remove Hyprland
pkill Hyprland
${pkgs.busybox}/bin/pkill Hyprland
# Unbind VTconsoles
echo 0 > /sys/class/vtconsole/vtcon0/bind
echo 0 > /sys/class/vtconsole/vtcon1/bind
${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon0/bind
${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon1/bind
# Unbind EFI-Framebuffer
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
# We love race conditions
sleep 2
${pkgs.busybox}/bin/echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
# Unload Modules
modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
${pkgs.busybox}/bin/modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
# Unbind the GPU from display driver
virsh nodedev-detach pci_0000_01_00_0
virsh nodedev-detach pci_0000_01_00_1
${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
modprobe vfio_pci
sleep 2
${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)
virsh nodedev-reattach pci_0000_01_00_0
virsh nodedev-reattach pci_0000_01_00_1
${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_0
${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_1
modprobe -r vfio-pci
${pkgs.busybox}/bin/modprobe -r vfio-pci
#bind efi
echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
${pkgs.busybox}/bin/echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
# Reload nvidia modules
modprobe nvidia_drm
modprobe nvidia_modeset
modprobe nvidia_uvm
modprobe nvidia
${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
echo 1 > /sys/class/vtconsole/vtcon0/bind
bin/echo 1 > /sys/class/vtconsole/vtcon1/bind
${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon0/bind
${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon1/bind
fi
@ -88,15 +79,6 @@ in {
steam-hardware.enable = true;
};
networking.networkmanager.enable = true;
services.syncthing = {
enable = true;
user = "stitchynyan";
openDefaultPorts = true;
databaseDir = "/home/stitchynyan/.local/share/syncthing";
dataDir = "/home/stitchynyan";
};
networking.hostName = "malachite";
time.timeZone = "America/Los_Angeles";

View file

@ -7,7 +7,7 @@
boot.initrd.availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" "vfio-pci" ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
boot.kernelParams = [