mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
further i3 configration, VFIO overhaul
This commit is contained in:
parent
29c6d142f8
commit
9dbef76fad
15 changed files with 542 additions and 90 deletions
|
|
@ -193,17 +193,84 @@
|
|||
'';
|
||||
|
||||
services.xserver= {
|
||||
xrandrHeads = [
|
||||
{
|
||||
output = "HDMI-A-0";
|
||||
primary = true;
|
||||
}
|
||||
];
|
||||
extraConfig = ''
|
||||
Section "Monitor"
|
||||
Identifier "DisplayPort-0"
|
||||
Option "PreferredMode" "1920x1080"
|
||||
Option "Position" "0 0"
|
||||
EndSection
|
||||
Section "Monitor"
|
||||
Identifier "HDMI-A-0"
|
||||
Option "Primary" "true"
|
||||
Option "PreferredMode" "1920x1080"
|
||||
Option "Position" "1920 0"
|
||||
EndSection
|
||||
Section "Monitor"
|
||||
Identifier "DVI-D-0"
|
||||
Option "PreferredMode" "1920x1200"
|
||||
Option "Position" "3840 0"
|
||||
EndSection
|
||||
'';
|
||||
deviceSection = ''
|
||||
Option "monitor-HDMI-A-0" "HDMI-A-0"
|
||||
Option "monitor-DisplayPort-0" "DisplayPort-0"
|
||||
Option "monitor-DVI-D-0" "DVI-D-0"
|
||||
BusID "PCI:37:0:0"
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
environment.etc = {
|
||||
"sensors3.conf".text = ''
|
||||
chip "nct6797-isa-0a20"
|
||||
label in0 "Vcore"
|
||||
label in1 "+5V"
|
||||
compute in1 5*@, @/5
|
||||
label in2 "AVCC"
|
||||
set in2_min 3.3 * 0.90
|
||||
set in2_max 3.3 * 1.10
|
||||
label in3 "+3.3V"
|
||||
set in3_min 3.3 * 0.90
|
||||
set in3_max 3.3 * 1.10
|
||||
label in4 "+12V"
|
||||
compute in4 12*@, @/12
|
||||
label in5 "DIMM"
|
||||
compute in5 (8+18/19)*@, @/(8+18/19)
|
||||
# label in6 "wtf?" # can't find this in hwinfo64?
|
||||
label in7 "3VSB"
|
||||
set in7_min 3.3 * 0.90
|
||||
set in7_max 3.3 * 1.10
|
||||
label in8 "Vbat"
|
||||
set in8_min 3.3 * 0.90
|
||||
set in8_max 3.3 * 1.10
|
||||
label in9 "VTT"
|
||||
ignore in10 # always zero
|
||||
# label in11 "VIN4" # on hwinfo64
|
||||
label in12 "SoC" # "CPU NB" on hwinfo64
|
||||
# label in13 "VIN6" # on hwinfo64
|
||||
# label in13 "VIN7" # on hwinfo64
|
||||
label fan1 "Rear Fan" # "Pump Fan"
|
||||
label fan2 "CPU Fan"
|
||||
label fan3 "Top Exhaust" # "Case Fan 1"
|
||||
label fan4 "Front Fan" # "Case Fan 2"
|
||||
label fan5 "Top Intake" # "Case Fan 3"
|
||||
label fan6 "Front Fan" # "Case Fan 4"
|
||||
label temp7 "Core"
|
||||
label temp1 "Motherboard"
|
||||
label temp2 "CPU"
|
||||
label temp3 "System" # Auxillary
|
||||
ignore temp4
|
||||
ignore temp6
|
||||
ignore temp8
|
||||
ignore temp9
|
||||
ignore temp10
|
||||
ignore intrusion0
|
||||
ignore intrusion1
|
||||
ignore beep_enable
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
networking = {
|
||||
hostId = "617050fc";
|
||||
useDHCP = false;
|
||||
|
|
@ -218,6 +285,111 @@
|
|||
firewall.allowPing = true;
|
||||
};
|
||||
|
||||
/* boot.kernel.sysctl = let
|
||||
nct = ".//.//.sys.devices.platform.nct6775/2592.hwmon.hwmon1";
|
||||
in {
|
||||
# rear exhaust
|
||||
#"${nct}.pwm1_mode" = 0;
|
||||
"${nct}.pwm1_temp_sel" = 2;
|
||||
"${nct}.pwm1_enable" = 5;
|
||||
"${nct}.pwm1_auto_point1_temp" = 35000;
|
||||
"${nct}.pwm1_auto_point1_pwm" = 88;
|
||||
"${nct}.pwm1_auto_point2_temp" = 38000;
|
||||
"${nct}.pwm1_auto_point2_pwm" = 104;
|
||||
"${nct}.pwm1_auto_point3_temp" = 47000;
|
||||
"${nct}.pwm1_auto_point3_pwm" = 144;
|
||||
"${nct}.pwm1_auto_point4_temp" = 49000;
|
||||
"${nct}.pwm1_auto_point4_pwm" = 224;
|
||||
"${nct}.pwm1_auto_point5_temp" = 52000;
|
||||
"${nct}.pwm1_auto_point5_pwm" = 255;
|
||||
"${nct}.pwm1_step_up_time" = 150;
|
||||
"${nct}.pwm1_step_down_time" = 150;
|
||||
|
||||
# cpu fan
|
||||
#${nct}.pwm2_mode=0
|
||||
"${nct}.pwm2_temp_sel" = 2;
|
||||
"${nct}.pwm2_enable" = 5;
|
||||
"${nct}.pwm2_auto_point1_temp" = 34000;
|
||||
"${nct}.pwm2_auto_point1_pwm" = 0;
|
||||
"${nct}.pwm2_auto_point2_temp" = 34500;
|
||||
"${nct}.pwm2_auto_point2_pwm" = 128;
|
||||
"${nct}.pwm2_auto_point3_temp" = 47000;
|
||||
"${nct}.pwm2_auto_point3_pwm" = 160;
|
||||
"${nct}.pwm2_auto_point4_temp" = 49000;
|
||||
"${nct}.pwm2_auto_point4_pwm" = 224;
|
||||
"${nct}.pwm2_auto_point5_temp" = 52000;
|
||||
"${nct}.pwm2_auto_point5_pwm" = 255;
|
||||
"${nct}.pwm2_step_up_time" = 50;
|
||||
"${nct}.pwm2_step_down_time" = 50;
|
||||
|
||||
# top exhaust
|
||||
#"${nct}.pwm3_mode" = 0;
|
||||
"${nct}.pwm3_temp_sel" = 2;
|
||||
"${nct}.pwm3_enable" = 5;
|
||||
"${nct}.pwm3_auto_point1_temp" = 36000;
|
||||
"${nct}.pwm3_auto_point1_pwm" = 0;
|
||||
"${nct}.pwm3_auto_point2_temp" = 39000;
|
||||
"${nct}.pwm3_auto_point2_pwm" = 136;
|
||||
"${nct}.pwm3_auto_point3_temp" = 48000;
|
||||
"${nct}.pwm3_auto_point3_pwm" = 144;
|
||||
"${nct}.pwm3_auto_point4_temp" = 50000;
|
||||
"${nct}.pwm3_auto_point4_pwm" = 176;
|
||||
"${nct}.pwm3_auto_point5_temp" = 53000;
|
||||
"${nct}.pwm3_auto_point5_pwm" = 255;
|
||||
"${nct}.pwm3_step_up_time" = 100;
|
||||
"${nct}.pwm3_step_down_time" = 100;
|
||||
|
||||
# front 1
|
||||
#"${nct}.pwm4_mode" = 0;
|
||||
"${nct}.pwm4_temp_sel" = 2;
|
||||
"${nct}.pwm4_enable" = 5;
|
||||
"${nct}.pwm4_auto_point1_temp" = 35000;
|
||||
"${nct}.pwm4_auto_point1_pwm" = 104;
|
||||
"${nct}.pwm4_auto_point2_temp" = 38000;
|
||||
"${nct}.pwm4_auto_point2_pwm" = 176;
|
||||
"${nct}.pwm4_auto_point3_temp" = 47000;
|
||||
"${nct}.pwm4_auto_point3_pwm" = 192;
|
||||
"${nct}.pwm4_auto_point4_temp" = 49000;
|
||||
"${nct}.pwm4_auto_point4_pwm" = 224;
|
||||
"${nct}.pwm4_auto_point5_temp" = 52000;
|
||||
"${nct}.pwm4_auto_point5_pwm" = 255;
|
||||
"${nct}.pwm4_step_up_time" = 100;
|
||||
"${nct}.pwm4_step_down_time" = 100;
|
||||
|
||||
# top intake
|
||||
#"${nct}.pwm5_mode" = 0;
|
||||
"${nct}.pwm5_temp_sel" = 2;
|
||||
"${nct}.pwm5_enable" = 5;
|
||||
"${nct}.pwm5_auto_point1_temp" = 36000;
|
||||
"${nct}.pwm5_auto_point1_pwm" = 104;
|
||||
"${nct}.pwm5_auto_point2_temp" = 39000;
|
||||
"${nct}.pwm5_auto_point2_pwm" = 144;
|
||||
"${nct}.pwm5_auto_point3_temp" = 48000;
|
||||
"${nct}.pwm5_auto_point3_pwm" = 176;
|
||||
"${nct}.pwm5_auto_point4_temp" = 50000;
|
||||
"${nct}.pwm5_auto_point4_pwm" = 208;
|
||||
"${nct}.pwm5_auto_point5_temp" = 53000;
|
||||
"${nct}.pwm5_auto_point5_pwm" = 255;
|
||||
"${nct}.pwm5_step_up_time" = 100;
|
||||
"${nct}.pwm5_step_down_time" = 100;
|
||||
|
||||
# front 2
|
||||
#"${nct}.pwm6_mode" = 0;
|
||||
"${nct}.pwm6_temp_sel" = 2;
|
||||
"${nct}.pwm6_enable" = 5;
|
||||
"${nct}.pwm6_auto_point1_temp" = 35000;
|
||||
"${nct}.pwm6_auto_point1_pwm" = 104;
|
||||
"${nct}.pwm6_auto_point2_temp" = 38000;
|
||||
"${nct}.pwm6_auto_point2_pwm" = 176;
|
||||
"${nct}.pwm6_auto_point3_temp" = 47000;
|
||||
"${nct}.pwm6_auto_point3_pwm" = 192;
|
||||
"${nct}.pwm6_auto_point4_temp" = 49000;
|
||||
"${nct}.pwm6_auto_point4_pwm" = 224;
|
||||
"${nct}.pwm6_auto_point5_temp" = 52000;
|
||||
"${nct}.pwm6_auto_point5_pwm" = 255;
|
||||
"${nct}.pwm6_step_up_time" = 100;
|
||||
"${nct}.pwm6_step_down_time" = 100;
|
||||
}; */
|
||||
/*systemd.network = {
|
||||
networks.enp34s0 = {
|
||||
matchConfig.Name = "enp34s0";
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
};
|
||||
};
|
||||
polybarExtend = { config, ... }: {
|
||||
services.polybar.settings."module/temp".hwmon-path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp2_input";
|
||||
services.polybar.settings."module/temp".hwmon-path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp1_input";
|
||||
};
|
||||
/*
|
||||
polybarExtend2 = { config, ... }: {
|
||||
|
|
|
|||
|
|
@ -1,75 +1,91 @@
|
|||
{ config, pkgs, lib, ... }: with lib; let
|
||||
screenstubConfig = let
|
||||
jsonConfig = builtins.toJSON {
|
||||
exit_events = [ "show_host" ];
|
||||
hotkeys = [
|
||||
{
|
||||
events = [
|
||||
{ toggle_grab = { x = { mouse = false; }; }; }
|
||||
{
|
||||
toggle_grab = {
|
||||
evdev = {
|
||||
devices = [
|
||||
"/dev/input/by-id/usb-Razer_Razer_Naga_Trinity_00000000001A-event-mouse"
|
||||
];
|
||||
evdev_ignore = [ "button" ];
|
||||
exclusive = false;
|
||||
xcore_ignore = [ "absolute" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
"unstick_host"
|
||||
];
|
||||
modifiers = [ "LeftMeta" ];
|
||||
triggers = [ "Esc" ];
|
||||
}
|
||||
{
|
||||
events = [ "toggle_show" ];
|
||||
modifiers = [ "LeftMeta" ];
|
||||
on_release = false;
|
||||
triggers = [ "T" ];
|
||||
}
|
||||
];
|
||||
key_remap = {
|
||||
LeftMeta = "Reserved";
|
||||
RightAlt = "LeftMeta";
|
||||
};
|
||||
qemu = {
|
||||
absolute_driver = { virtio = { bus = "pci.21"; }; };
|
||||
ga_socket = "/tmp/vfio-qga";
|
||||
keyboard_driver = { virtio = { bus = "pci.23"; }; };
|
||||
qmp_socket = "/tmp/vfio-qmp";
|
||||
relative_driver = { virtio = { bus = "pci.22"; }; };
|
||||
routing = "virtio-host";
|
||||
};
|
||||
screens = [{
|
||||
ddc = {
|
||||
guest = [ "ddc" ];
|
||||
host = [ "ddc" ];
|
||||
};
|
||||
guest_source = { name = "HDMI-1"; };
|
||||
host_source = { name = "HDMI-2"; };
|
||||
monitor = {
|
||||
manufacturer = "BNQ";
|
||||
model = "BenQ GW2270";
|
||||
};
|
||||
}];
|
||||
}; in pkgs.writeText "screenstub.json" jsonConfig;
|
||||
win10-screenstub = pkgs.writeShellScriptBin "win10-screenstub" ''
|
||||
${pkgs.screenstub}/bin/screenstub -c "${screenstubConfig}" x
|
||||
win10-toggler = pkgs.writeShellScriptBin "win10-toggle" ''
|
||||
if systemctl --user is-active konawall-rotation.timer --quiet; then
|
||||
systemctl --user stop konawall-rotation.timer
|
||||
else
|
||||
systemctl --user start konawall-rotation.timer
|
||||
fi
|
||||
sudo win10-vm-pinning $(cat $XDG_RUNTIME_DIR/win10-vm.pid)
|
||||
'';
|
||||
win10-diskmapper = pkgs.writeShellScriptBin "win10-diskmapper" ''
|
||||
sudo ${pkgs.disk-mapper}/bin/disk-mapper /dev/disk/by-id/ata-ST2000DM008-2FR102_WK301C3H-part2
|
||||
win10-start-pane = pkgs.writeShellScriptBin "win10-start-pane" ''
|
||||
sudo disk-mapper-part /dev/disk/by-id/ata-ST2000DM008-2FR102_WK301C3H-part2
|
||||
sudo chown kat:users /dev/mapper/ata-ST2000DM008-2FR102_WK301C3H-part2
|
||||
echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null || true; echo 1 | sudo tee /proc/sys/vm/compact_memory > /dev/null || true
|
||||
win10-vm -pidfile $XDG_RUNTIME_DIR/win10-vm.pid
|
||||
'';
|
||||
in
|
||||
{
|
||||
win10-start = pkgs.writeShellScriptBin "win10-start" ''
|
||||
tmux new-session -ds vm "${win10-start-pane}/bin/win10-start-pane" \; split-window -h 'sleep 10; screenstub x'
|
||||
'';
|
||||
in {
|
||||
options.home-manager.users = let
|
||||
userVFIOExtend = { config, ... }: {
|
||||
config = mkIf config.wayland.windowManager.sway.enable {
|
||||
config = mkMerge [
|
||||
(mkIf config.wayland.windowManager.sway.enable {
|
||||
wayland.windowManager.sway.config.input = mapListToAttrs (t:
|
||||
nameValuePair "5824:1503:screenstub-${t}" ({ events = "disabled"; })
|
||||
) [ "tablet" "mouse" "kbd" ];
|
||||
};
|
||||
})
|
||||
{
|
||||
programs.screenstub = {
|
||||
enable = true;
|
||||
settings = {
|
||||
exit_events = [ "show_host" ];
|
||||
hotkeys = [
|
||||
{
|
||||
events = [
|
||||
{ toggle_grab = { x = { mouse = false; }; }; }
|
||||
{
|
||||
toggle_grab = {
|
||||
evdev = {
|
||||
devices = [
|
||||
"/dev/input/by-id/usb-Razer_Razer_Naga_Trinity_00000000001A-event-mouse"
|
||||
];
|
||||
evdev_ignore = [ "button" ];
|
||||
exclusive = false;
|
||||
xcore_ignore = [ "absolute" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
"unstick_host"
|
||||
];
|
||||
modifiers = [ "LeftMeta" ];
|
||||
triggers = [ "Esc" ];
|
||||
}
|
||||
{
|
||||
events = [ "toggle_show" ];
|
||||
modifiers = [ "LeftMeta" ];
|
||||
on_release = false;
|
||||
triggers = [ "T" ];
|
||||
}
|
||||
];
|
||||
key_remap = {
|
||||
LeftMeta = "Reserved";
|
||||
RightAlt = "LeftMeta";
|
||||
};
|
||||
qemu = {
|
||||
absolute_driver = { virtio = { bus = "pci.21"; }; };
|
||||
ga_socket = "/tmp/vfio-qga";
|
||||
keyboard_driver = { virtio = { bus = "pci.23"; }; };
|
||||
qmp_socket = "/tmp/vfio-qmp";
|
||||
relative_driver = { virtio = { bus = "pci.22"; }; };
|
||||
routing = "virtio-host";
|
||||
};
|
||||
screens = [{
|
||||
ddc = {
|
||||
guest = [ "ddc" ];
|
||||
host = [ "ddc" ];
|
||||
};
|
||||
guest_source = { name = "HDMI-1"; };
|
||||
host_source = { name = "HDMI-2"; };
|
||||
monitor = {
|
||||
manufacturer = "BNQ";
|
||||
model = "BenQ GW2270";
|
||||
};
|
||||
}];
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
in mkOption {
|
||||
type = types.attrsOf (types.submoduleWith {
|
||||
|
|
@ -81,12 +97,54 @@ in
|
|||
deploy.profile.vfio = true;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
win10-screenstub
|
||||
win10-vm
|
||||
win10-diskmapper
|
||||
win10-toggler
|
||||
vfio-vm
|
||||
vfio-vm-pinning
|
||||
vfio-disk-mapper
|
||||
win10-start
|
||||
ddcutil
|
||||
];
|
||||
|
||||
systemd.mounts = let
|
||||
hugepages = { where, options }: {
|
||||
before = ["sysinit.target"];
|
||||
unitConfig = {
|
||||
DefaultDependencies = "no";
|
||||
ConditionPathExists = "/sys/kernel/mm/hugepages";
|
||||
ConditionCapability = "CAP_SYS_ADMIN";
|
||||
ConditionVirtualization = "!private-users";
|
||||
};
|
||||
what = "hugetlbfs";
|
||||
inherit where options;
|
||||
type = "hugetlbfs";
|
||||
mountConfig = {
|
||||
Group = "vfio";
|
||||
};
|
||||
wantedBy = ["sysinit.target"];
|
||||
};
|
||||
cpuset = {
|
||||
type = "cgroup";
|
||||
what = "cpuset";
|
||||
where = "/sys/fs/cgroup/cpuset";
|
||||
wantedBy = singleton "multi-user.target";
|
||||
options = "cpuset";
|
||||
};
|
||||
in [
|
||||
cpuset
|
||||
(hugepages { where = "/dev/hugepages"; options = "mode=0775"; })
|
||||
(hugepages { where = "/dev/hugepages1G"; options = "pagesize=1GB,mode=0775"; })
|
||||
];
|
||||
|
||||
systemd.services.preallocate-huggies = {
|
||||
wantedBy = singleton "multi-user.target";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
};
|
||||
script = ''
|
||||
echo 12 > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
|
||||
'';
|
||||
};
|
||||
|
||||
users.groups = { uinput = { }; vfio = { }; };
|
||||
|
||||
boot = lib.mkMerge [{
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit fc7a2a7dea6f067bb3038ac01454030085b55097
|
||||
Subproject commit ab39c7fb9a3bb8250abbce9b66a1ede088919f12
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
mouse_middle_click = "context";
|
||||
mouse_left_click = "close_current";
|
||||
show_indicators = false;
|
||||
fullscreen = "pushback"; # default is to "show"
|
||||
#dmenu = "${config.programs.dmenu.package}/bin/dmenu";
|
||||
dmenu = "${config.programs.rofi.package}/bin/rofi";
|
||||
browser = "${pkgs.xdg-utils}/bin/xdg-open";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
{ config, base16, pkgs, lib, ... }: with lib;
|
||||
|
||||
{
|
||||
programs.zsh.loginExtra = ''
|
||||
if [[ -z "''${TMUX-}" && -z "''${DISPLAY-}" && "''${XDG_VTNR-}" = 1 && $(${pkgs.coreutils}/bin/id -u) != 0 ]]; then
|
||||
${pkgs.xorg.xinit}/bin/startx
|
||||
fi
|
||||
'';
|
||||
|
||||
services.i3gopher = { enable = true; };
|
||||
|
||||
home.file.".xinitrc".text = ''
|
||||
|
|
@ -27,10 +33,10 @@
|
|||
"7"
|
||||
"8"
|
||||
"9"
|
||||
]
|
||||
++ [ (bindWorkspace "0" "10:10") ]
|
||||
++ lib.imap1 (i: v: bindWorkspace v "${toString (10 + i)}:${v}") [
|
||||
"F1"
|
||||
]
|
||||
++ [ (bindWorkspace "0" "10:10") ]
|
||||
++ lib.imap1 (i: v: bindWorkspace v "${toString (10 + i)}:${v}") [
|
||||
"F1"
|
||||
"F2"
|
||||
"F3"
|
||||
"F4"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{ config, base16, lib, pkgs, ... }: with lib; {
|
||||
programs.rofi = {
|
||||
enable = true;
|
||||
terminal = "${pkgs.kitty}/bin/kitty";
|
||||
font = "${config.kw.theme.font.name} 9";
|
||||
theme = let
|
||||
# Use `mkLiteral` for string-like values that should show without
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue