Compare commits

...

2 commits

Author SHA1 Message Date
eb87bbcd16
moar malachite fixes 2024-04-05 02:40:39 -07:00
8d69eb76d6
better way of doing this 2024-04-05 02:23:54 -07:00
2 changed files with 63 additions and 45 deletions

View file

@ -1,65 +1,74 @@
{ config, pkgs, ... }:
{ config, pkgs, lib, ... }:
let
passthrough = pkgs.writeShellScript "pasthrough.sh" ''
GUEST_NAME="$1"
HOOK_NAME="$2"
STATE_NAME="$3"
passthrough = pkgs.writeShellApplication {
name = "pasthrough.sh";
runtimeInputs = lib.attrVals [ "coreutils" "kmod" "libvirtd" "procps" ] pkgs;
text = ''
GUEST_NAME="$1"
HOOK_NAME="$2"
STATE_NAME="$3"
set -e
set -x
echo 19>/home/stitchynyan/startlogfile
BASH_XTRACEFD=19
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
# Rebind VT consoles
${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon0/bind
${pkgs.busybox}/bin/echo 1 > /sys/class/vtconsole/vtcon1/bind
#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
fi
fi
'';
'';
in {
imports =
[
@ -79,6 +88,15 @@ 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" ];
boot.kernelModules = [ "kvm-intel" "vfio-pci" ];
boot.extraModulePackages = [ ];
boot.kernelParams = [