Compare commits
No commits in common. "eb87bbcd16e26f44a83cb1a7e9af56164cad068a" and "16ae89045854dc506c72f6253a2e9384cf247452" have entirely different histories.
eb87bbcd16
...
16ae890458
2 changed files with 45 additions and 63 deletions
|
@ -1,74 +1,65 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{ config, pkgs, ... }:
|
||||
let
|
||||
passthrough = pkgs.writeShellApplication {
|
||||
name = "pasthrough.sh";
|
||||
runtimeInputs = lib.attrVals [ "coreutils" "kmod" "libvirtd" "procps" ] pkgs;
|
||||
text = ''
|
||||
GUEST_NAME="$1"
|
||||
HOOK_NAME="$2"
|
||||
STATE_NAME="$3"
|
||||
passthrough = pkgs.writeShellScript "pasthrough.sh" ''
|
||||
GUEST_NAME="$1"
|
||||
HOOK_NAME="$2"
|
||||
STATE_NAME="$3"
|
||||
|
||||
echo 19>/home/stitchynyan/startlogfile
|
||||
BASH_XTRACEFD=19
|
||||
set -x
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# For the windows 10 VM
|
||||
if [[ "$GUEST_NAME" == "win10" ]]; then
|
||||
|
||||
# For the windows 10 VM
|
||||
if [[ "$GUEST_NAME" == "win10" ]]; then
|
||||
# Prepare hook
|
||||
if [[ "$HOOK_NAME/$STATE_NAME" == "prepare/begin" ]]; then
|
||||
|
||||
# Prepare hook
|
||||
if [[ "$HOOK_NAME/$STATE_NAME" == "prepare/begin" ]]; then
|
||||
# Remove Hyprland
|
||||
${pkgs.busybox}/bin/pkill Hyprland
|
||||
|
||||
# Remove Hyprland
|
||||
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 VTconsoles
|
||||
echo 0 > /sys/class/vtconsole/vtcon0/bind
|
||||
echo 0 > /sys/class/vtconsole/vtcon1/bind
|
||||
# Unbind EFI-Framebuffer
|
||||
${pkgs.busybox}/bin/echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
|
||||
|
||||
# Unbind EFI-Framebuffer
|
||||
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
|
||||
|
||||
# We love race conditions
|
||||
sleep 2
|
||||
# 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
|
||||
|
||||
# Unload Modules
|
||||
modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
|
||||
# Load VFIO Kernel Module
|
||||
${pkgs.busybox}/bin/modprobe vfio_pci
|
||||
|
||||
# Unbind the GPU from display driver
|
||||
virsh nodedev-detach pci_0000_01_00_0
|
||||
virsh nodedev-detach pci_0000_01_00_1
|
||||
elif [[ "$HOOK_NAME/$STATE_NAME" == "release/end" ]]; then
|
||||
|
||||
# Load VFIO Kernel Module
|
||||
modprobe vfio_pci
|
||||
# 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
|
||||
|
||||
sleep 2
|
||||
${pkgs.busybox}/bin/modprobe -r vfio-pci
|
||||
|
||||
elif [[ "$HOOK_NAME/$STATE_NAME" == "release/end" ]]; then
|
||||
#bind efi
|
||||
${pkgs.busybox}/bin/echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
modprobe -r vfio-pci
|
||||
|
||||
#bind efi
|
||||
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
|
||||
|
||||
# Rebind VT consoles
|
||||
echo 1 > /sys/class/vtconsole/vtcon0/bind
|
||||
bin/echo 1 > /sys/class/vtconsole/vtcon1/bind
|
||||
|
||||
fi
|
||||
# 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 =
|
||||
[
|
||||
|
@ -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";
|
||||
|
|
|
@ -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 = [
|
||||
|
|
Loading…
Reference in a new issue