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
|
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
|
# For the windows 10 VM
|
||||||
if [[ "$GUEST_NAME" == "win10" ]]; then
|
if [[ "$GUEST_NAME" == "win10" ]]; then
|
||||||
|
|
||||||
# Prepare hook
|
# Prepare hook
|
||||||
if [[ "$HOOK_NAME/$STATE_NAME" == "prepare/begin" ]]; then
|
if [[ "$HOOK_NAME/$STATE_NAME" == "prepare/begin" ]]; then
|
||||||
|
|
||||||
# Remove Hyprland
|
# Remove Hyprland
|
||||||
pkill Hyprland
|
${pkgs.busybox}/bin/pkill Hyprland
|
||||||
|
|
||||||
# Unbind VTconsoles
|
# Unbind VTconsoles
|
||||||
echo 0 > /sys/class/vtconsole/vtcon0/bind
|
${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon0/bind
|
||||||
echo 0 > /sys/class/vtconsole/vtcon1/bind
|
${pkgs.busybox}/bin/echo 0 > /sys/class/vtconsole/vtcon1/bind
|
||||||
|
|
||||||
# Unbind EFI-Framebuffer
|
# Unbind EFI-Framebuffer
|
||||||
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
|
${pkgs.busybox}/bin/echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
|
||||||
|
|
||||||
# We love race conditions
|
# Unload Modules
|
||||||
sleep 2
|
${pkgs.busybox}/bin/modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
|
||||||
|
|
||||||
# Unload Modules
|
# Unbind the GPU from display driver
|
||||||
modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
|
${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_0
|
||||||
|
${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_1
|
||||||
|
|
||||||
# Unbind the GPU from display driver
|
# Load VFIO Kernel Module
|
||||||
virsh nodedev-detach pci_0000_01_00_0
|
${pkgs.busybox}/bin/modprobe vfio_pci
|
||||||
virsh nodedev-detach pci_0000_01_00_1
|
|
||||||
|
|
||||||
# Load VFIO Kernel Module
|
elif [[ "$HOOK_NAME/$STATE_NAME" == "release/end" ]]; then
|
||||||
modprobe vfio_pci
|
|
||||||
|
|
||||||
sleep 2
|
# 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
|
||||||
|
|
||||||
elif [[ "$HOOK_NAME/$STATE_NAME" == "release/end" ]]; then
|
${pkgs.busybox}/bin/modprobe -r vfio-pci
|
||||||
|
|
||||||
# Re-Bind GPU to Nvidia Driver (replace the pci addresses with yours)
|
#bind efi
|
||||||
virsh nodedev-reattach pci_0000_01_00_0
|
${pkgs.busybox}/bin/echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
|
||||||
virsh nodedev-reattach pci_0000_01_00_1
|
|
||||||
|
|
||||||
modprobe -r vfio-pci
|
# 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
|
||||||
|
|
||||||
#bind efi
|
# Rebind VT consoles
|
||||||
echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
|
${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon0/bind
|
||||||
|
${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon1/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";
|
||||||
|
|
|
@ -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 = [
|
||||||
|
|
Loading…
Reference in a new issue