funny tmpfiles

This commit is contained in:
Gerg-L 2023-11-03 19:49:43 -04:00
parent 7eb0c12fd1
commit b66e783d26
Signed by: gerg-l
SSH key fingerprint: SHA256:FPYDHIkvMocr4wdmZXpgpJjsb2Tw6rASs2ISPbOb0KI

View file

@ -145,9 +145,11 @@ in
''; '';
systemd.tmpfiles.rules = systemd.tmpfiles.settings."vfio" = {
let "/etc/Xorg/active.conf"."L".argument = "/etc/Xorg/2_mon.conf";
qemuHook = pkgs.writeShellApplication { "/var/lib/libvirt/qemu/Windows.xml"."L+".argument = toString ./Windows.xml;
"/var/lib/libvirt/hooks/qemu"."L+".argument = lib.getExe (
pkgs.writeShellApplication {
name = "qemu-hook"; name = "qemu-hook";
runtimeInputs = [ runtimeInputs = [
@ -160,38 +162,37 @@ in
OPERATION="$2" OPERATION="$2"
if [ "$GUEST_NAME" == "Windows" ]; then if [ "$GUEST_NAME" == "Windows" ]; then
if [ "$OPERATION" == "prepare" ]; then exit 0
systemctl stop display-manager.service fi
modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
virsh nodedev-detach pci_0000_01_00_0 if [ "$OPERATION" == "prepare" ]; then
virsh nodedev-detach pci_0000_01_00_1
systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31
systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31
systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31
ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf
touch /etc/Xorg/ONE_MONITOR
systemctl start display-manager.service
fi
if [ "$OPERATION" == "release" ]; then
systemctl stop display-manager.service systemctl stop display-manager.service
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31 modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31 virsh nodedev-detach pci_0000_01_00_0
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31 virsh nodedev-detach pci_0000_01_00_1
virsh nodedev-reattach pci_0000_01_00_0 systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31
virsh nodedev-reattach pci_0000_01_00_1 systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31
ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf
rm /etc/Xorg/ONE_MONITOR touch /etc/Xorg/ONE_MONITOR
systemctl start display-manager.service systemctl start display-manager.service
fi fi
if [ "$OPERATION" == "release" ]; then
systemctl stop display-manager.service
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
virsh nodedev-reattach pci_0000_01_00_0
virsh nodedev-reattach pci_0000_01_00_1
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf
rm /etc/Xorg/ONE_MONITOR
systemctl start display-manager.service
fi fi
''; '';
}; }
in );
[ };
"L /etc/Xorg/active.conf - - - - /etc/Xorg/2_mon.conf"
"C /var/lib/libvirt/hooks/qemu - - - - ${lib.getExe qemuHook}"
"C /var/lib/libvirt/qemu/Windows.xml - - - - ${./Windows.xml}"
];
_file = ./vfio.nix; _file = ./vfio.nix;
} }