hosts: Improve the passthrough experience

This commit is contained in:
PapaTutuWawa 2021-08-12 13:29:53 +02:00
parent 18655bd56c
commit ed62c46cbd
2 changed files with 90 additions and 12 deletions

View File

@ -54,7 +54,7 @@ in
}; };
# We don't tolerate non-free software, except for Steam and Linux firmware # We don't tolerate non-free software, except for Steam and Linux firmware
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "firmwareLinuxNonfree" ]; nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "firmwareLinuxNonfree" "steam" "steam-original" "steam-runtime"];
services = { services = {
connman = { connman = {

View File

@ -37,14 +37,68 @@ in {
gamemode # Custom package gamemode # Custom package
key-mapper # Custom package key-mapper # Custom package
replaysorcery # Custom package replaysorcery # Custom package
evdev-proxy # Custom package
scream scream
steam
linuxPackages_zen.vendor-reset linuxPackages_zen.vendor-reset
]; ];
sessionVariables = { sessionVariables = {
# Prevent us from having to always type it out # Prevent us from having to always type it out
#NIXOS_CONFIG = "\${HOME}/Development/Personal/nixos-config/hosts/miku.nix"; #NIXOS_CONFIG = "\${HOME}/Development/Personal/nixos-config/hosts/miku.nix";
}; };
etc = {
"evdev-proxy/config.toml".source = pkgs.writeText "config.toml" ''
log_level = "INFO"
[[device]]
[device.Simple]
name = "EvdevProxyMouse"
vendor = 0x1337
model = 0x1337
class = "Mouse"
[[device.Simple.selector]]
USBIDClass = {vendor=0x046d, model=0xc531, class="Mouse"}
[[device.Simple.selector]]
USBIDClass = {vendor=0x046d, model=0xc07c, class="Mouse"}
[[device]]
[device.Simple]
name = "EvdevProxyTartarus"
vendor = 0x1337
model = 0x1338
class = "Mouse"
[[device.Simple.selector]]
USBIDClass = {vendor=0x1532, model=0x022b, class="Keyboard"}
[[device.Simple.selector]]
EVDEVClass = {phys="\"key-mapper\""}
'';
"libvirt/hooks/qemu" = {
source = pkgs.writeText "qemu" ''
#!/bin/sh
guest=$1
phase=$2
state=$3
what=$4
if [[ "$guest" = "win10" ]]; then
case "$phase" in
"prepare")
sudo -u alexander systemctl --user start evdev-proxy
;;
"start")
sudo -u alexander systemctl --user start scream
;;
"stopped")
sudo -u alexander systemctl --user stop scream
sudo -u alexander systemctl --user stop evdev-proxy
esac
end
'';
mode = "0755";
};
};
}; };
networking = { networking = {
@ -98,6 +152,12 @@ in {
xserver.videoDrivers = [ "amdgpu" ]; xserver.videoDrivers = [ "amdgpu" ];
udev.extraRules = '' udev.extraRules = ''
KERNEL=="uinput", GROUP="input" KERNEL=="uinput", GROUP="input"
# This rule allows the input group to access /dev/uinput device to create virtual input devices
KERNEL=="uinput", SUBSYSTEM=="misc", GROUP="input", MODE="660"
# Create rules for your virtual devices to get persistent names
KERNEL=="event*", SUBSYSTEM=="input", ATTRS{name}=="EvdevProxy*", SYMLINK+="input/by-id/virtual-event-$attr{name}"
''; '';
sshd.enable = true; sshd.enable = true;
@ -106,18 +166,18 @@ in {
virtualisation.libvirtd = { virtualisation.libvirtd = {
enable = true; enable = true;
qemuOvmf = true; qemuOvmf = true;
qemuRunAsRoot = false; #qemuRunAsRoot = false;
qemuPackage = unstable.qemu;
qemuVerbatimConfig = '' qemuVerbatimConfig = ''
user = "alexander" seccomp_sandbox = 0
cgroup_device_acl = [ cgroup_device_acl = [
"/dev/null", "/dev/zero", "/dev/full", "/dev/null", "/dev/full", "/dev/zero",
"/dev/random", "/dev/kvm", "/dev/kqemu", "/dev/random", "/dev/urandom",
"/dev/rtc", "/dev/hpet", "/dev/ptmx", "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
"/dev/input/by-id/usb-Logitech_G700s_Rechargeable_Gaming_Mouse_93DF48160007-event-mouse", "/dev/rtc","/dev/hpet",
"/dev/input/by-id/usb-Razer_Razer_BlackWidow_Ultimate-event-kbd", "/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse",
"/dev/input/by-id/usb-Razer_Razer_BlackWidow_Ultimate-if01-event-kbd", "/dev/input/by-id/usb-Razer_Razer_Tartarus_V2-event-kbd",
"/dev/input/by-id/usb-Razer_Razer_BlackWidow_Ultimate-if02-event-mouse", "/dev/input/by-id/virtual-event-EvdevProxyMouse"
"/dev/input/by-id/usb-Razer_Razer_BlackWidow_Ultimate-event-if01"
] ]
''; '';
}; };
@ -143,6 +203,15 @@ in {
Restart = "always"; Restart = "always";
}; };
}; };
key-mapper = {
description = "A tool to change the mapping of your input device buttons";
wantedBy = [ "default.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.key-mapper}/bin/key-mapper-service";
Restart = "always";
};
};
replaysorcery = { replaysorcery = {
description = "An open-source, instant-replay solution for Linux"; description = "An open-source, instant-replay solution for Linux";
#wantedBy = [ "default.target" ]; #wantedBy = [ "default.target" ];
@ -153,6 +222,15 @@ in {
Restart = "always"; Restart = "always";
}; };
}; };
evdev-proxy = {
description = "Creates virtual device to proxy evdev devices events";
#wantedBy = [ "default.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.evdev-proxy}/bin/evdev-proxy";
Restart = "always";
};
};
gamemode = { gamemode = {
description = "A daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS."; description = "A daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS.";
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];