forked from stitchy/dotfiles
better way of doing this
This commit is contained in:
parent
16ae890458
commit
8d69eb76d6
1 changed files with 53 additions and 44 deletions
|
@ -1,11 +1,15 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
passthrough = pkgs.writeShellScript "pasthrough.sh" ''
|
passthrough = pkgs.writeShellApplication {
|
||||||
|
name = "pasthrough.sh";
|
||||||
|
runtimeInputs = lib.attrVals [ "coreutils" "kmod" "libvirtd" "procps" ] pkgs;
|
||||||
|
text = ''
|
||||||
GUEST_NAME="$1"
|
GUEST_NAME="$1"
|
||||||
HOOK_NAME="$2"
|
HOOK_NAME="$2"
|
||||||
STATE_NAME="$3"
|
STATE_NAME="$3"
|
||||||
|
|
||||||
set -e
|
echo 19>/home/stitchynyan/startlogfile
|
||||||
|
BASH_XTRACEFD=19
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# For the windows 10 VM
|
# For the windows 10 VM
|
||||||
|
@ -15,45 +19,50 @@ let
|
||||||
if [[ "$HOOK_NAME/$STATE_NAME" == "prepare/begin" ]]; then
|
if [[ "$HOOK_NAME/$STATE_NAME" == "prepare/begin" ]]; then
|
||||||
|
|
||||||
# Remove Hyprland
|
# Remove Hyprland
|
||||||
${pkgs.busybox}/bin/pkill Hyprland
|
pkill Hyprland
|
||||||
|
|
||||||
# Unbind VTconsoles
|
# Unbind VTconsoles
|
||||||
${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon0/bind
|
echo 0 > /sys/class/vtconsole/vtcon0/bind
|
||||||
${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon1/bind
|
echo 0 > /sys/class/vtconsole/vtcon1/bind
|
||||||
|
|
||||||
# Unbind EFI-Framebuffer
|
# Unbind EFI-Framebuffer
|
||||||
${pkgs.busybox}/bin/echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
|
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
|
||||||
|
|
||||||
|
# We love race conditions
|
||||||
|
sleep 2
|
||||||
|
|
||||||
# Unload Modules
|
# Unload Modules
|
||||||
${pkgs.busybox}/bin/modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
|
modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
|
||||||
|
|
||||||
# Unbind the GPU from display driver
|
# Unbind the GPU from display driver
|
||||||
${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_0
|
virsh nodedev-detach pci_0000_01_00_0
|
||||||
${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_1
|
virsh nodedev-detach pci_0000_01_00_1
|
||||||
|
|
||||||
# Load VFIO Kernel Module
|
# Load VFIO Kernel Module
|
||||||
${pkgs.busybox}/bin/modprobe vfio_pci
|
modprobe vfio_pci
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
|
||||||
elif [[ "$HOOK_NAME/$STATE_NAME" == "release/end" ]]; then
|
elif [[ "$HOOK_NAME/$STATE_NAME" == "release/end" ]]; then
|
||||||
|
|
||||||
# Re-Bind GPU to Nvidia Driver (replace the pci addresses with yours)
|
# Re-Bind GPU to Nvidia Driver (replace the pci addresses with yours)
|
||||||
${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_0
|
virsh nodedev-reattach pci_0000_01_00_0
|
||||||
${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_1
|
virsh nodedev-reattach pci_0000_01_00_1
|
||||||
|
|
||||||
${pkgs.busybox}/bin/modprobe -r vfio-pci
|
modprobe -r vfio-pci
|
||||||
|
|
||||||
#bind efi
|
#bind efi
|
||||||
${pkgs.busybox}/bin/echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
|
echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
|
||||||
|
|
||||||
# Reload nvidia modules
|
# Reload nvidia modules
|
||||||
${pkgs.busybox}/bin/modprobe nvidia_drm
|
modprobe nvidia_drm
|
||||||
${pkgs.busybox}/bin/modprobe nvidia_modeset
|
modprobe nvidia_modeset
|
||||||
${pkgs.busybox}/bin/modprobe nvidia_uvm
|
modprobe nvidia_uvm
|
||||||
${pkgs.busybox}/bin/modprobe nvidia
|
modprobe nvidia
|
||||||
|
|
||||||
# Rebind VT consoles
|
# Rebind VT consoles
|
||||||
${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon0/bind
|
echo 1 > /sys/class/vtconsole/vtcon0/bind
|
||||||
${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon1/bind
|
bin/echo 1 > /sys/class/vtconsole/vtcon1/bind
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue