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,74 +1,65 @@
{ config, pkgs, lib, ... }: { config, pkgs, ... }:
let let
passthrough = pkgs.writeShellApplication { passthrough = pkgs.writeShellScript "pasthrough.sh" ''
name = "pasthrough.sh"; GUEST_NAME="$1"
runtimeInputs = lib.attrVals [ "coreutils" "kmod" "libvirtd" "procps" ] pkgs; HOOK_NAME="$2"
text = '' STATE_NAME="$3"
GUEST_NAME="$1"
HOOK_NAME="$2"
STATE_NAME="$3"
echo 19>/home/stitchynyan/startlogfile set -e
BASH_XTRACEFD=19 set -x
set -x
# For the windows 10 VM
if [[ "$GUEST_NAME" == "win10" ]]; then
# For the windows 10 VM # Prepare hook
if [[ "$GUEST_NAME" == "win10" ]]; then if [[ "$HOOK_NAME/$STATE_NAME" == "prepare/begin" ]]; then
# Prepare hook # Remove Hyprland
if [[ "$HOOK_NAME/$STATE_NAME" == "prepare/begin" ]]; then ${pkgs.busybox}/bin/pkill Hyprland
# Remove Hyprland # Unbind VTconsoles
pkill Hyprland ${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon0/bind
${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon1/bind
# Unbind VTconsoles # Unbind EFI-Framebuffer
echo 0 > /sys/class/vtconsole/vtcon0/bind ${pkgs.busybox}/bin/echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
echo 0 > /sys/class/vtconsole/vtcon1/bind
# Unbind EFI-Framebuffer # Unload Modules
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind ${pkgs.busybox}/bin/modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
# We love race conditions # Unbind the GPU from display driver
sleep 2 ${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_0
${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_1
# Unload Modules # Load VFIO Kernel Module
modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia ${pkgs.busybox}/bin/modprobe vfio_pci
# Unbind the GPU from display driver elif [[ "$HOOK_NAME/$STATE_NAME" == "release/end" ]]; then
virsh nodedev-detach pci_0000_01_00_0
virsh nodedev-detach pci_0000_01_00_1
# Load VFIO Kernel Module # Re-Bind GPU to Nvidia Driver (replace the pci addresses with yours)
modprobe vfio_pci ${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) # Reload nvidia modules
virsh nodedev-reattach pci_0000_01_00_0 ${pkgs.busybox}/bin/modprobe nvidia_drm
virsh nodedev-reattach pci_0000_01_00_1 ${pkgs.busybox}/bin/modprobe nvidia_modeset
${pkgs.busybox}/bin/modprobe nvidia_uvm
${pkgs.busybox}/bin/modprobe nvidia
modprobe -r vfio-pci # Rebind VT consoles
${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon0/bind
#bind efi ${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon1/bind
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
fi fi
''; fi
'';
in { in {
imports = imports =
[ [
@ -88,15 +79,6 @@ in {
steam-hardware.enable = true; 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"; networking.hostName = "malachite";
time.timeZone = "America/Los_Angeles"; 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.availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" "vfio-pci" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
boot.kernelParams = [ boot.kernelParams = [