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