2024-10-14 23:53:48 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
self,
|
|
|
|
...
|
2024-10-15 15:42:52 -04:00
|
|
|
}: let
|
|
|
|
legion-go-tricks = pkgs.fetchFromGitHub {
|
|
|
|
owner = "aarron-lee";
|
|
|
|
repo = "legion-go-tricks";
|
|
|
|
rev = "773f4dfa217989213ab2678d63a84dc306e8f8d4";
|
|
|
|
sha256 = "sha256-d5TB4kvNR7bwF5VyO1hxe8n9/PubtzWlBgvSmpUgDQc=";
|
|
|
|
};
|
|
|
|
|
|
|
|
convolverPath = "${legion-go-tricks}/experimental_sound_fix/multiwayCor48.wav";
|
|
|
|
in {
|
2024-10-14 23:53:48 -04:00
|
|
|
imports = [
|
|
|
|
self.nixosModules.hw-common-amd-cpu
|
|
|
|
self.nixosModules.hw-common-amd-gpu
|
|
|
|
self.nixosModules.hw-common-bluetooth
|
|
|
|
self.nixosModules.hw-common-ssd
|
|
|
|
];
|
|
|
|
|
|
|
|
boot = {
|
|
|
|
initrd = {
|
|
|
|
availableKernelModules = [
|
|
|
|
"amdgpu"
|
|
|
|
"nvme"
|
|
|
|
"rtsx_pci_sdmmc"
|
|
|
|
"sd_mod"
|
|
|
|
"sdhci_pci"
|
|
|
|
"thunderbolt"
|
|
|
|
"usb_storage"
|
|
|
|
"usbhid"
|
|
|
|
"xhci_pci"
|
|
|
|
];
|
|
|
|
|
|
|
|
kernelModules = ["amdgpu"];
|
|
|
|
};
|
|
|
|
|
2024-10-20 11:46:59 -04:00
|
|
|
blacklistedKernelModules = ["k10temp"]; # Conflicts with zenpower
|
2024-10-14 23:53:48 -04:00
|
|
|
extraModulePackages = with config.boot.kernelPackages; [acpi_call zenpower];
|
2024-10-20 01:46:11 -04:00
|
|
|
|
|
|
|
kernel.sysctl = {
|
2024-10-20 11:46:59 -04:00
|
|
|
# Improved file monitoring
|
2024-10-20 01:46:11 -04:00
|
|
|
"fs.inotify.max_user_instances" = 8192;
|
|
|
|
"fs.inotify.max_user_watches" = 524288;
|
2024-10-20 11:46:59 -04:00
|
|
|
|
|
|
|
# Disable wtachdogs for maximum performance at the cost of resiliency
|
2024-10-20 01:46:11 -04:00
|
|
|
"kernel.nmi_watchdog" = 0;
|
|
|
|
"kernel.soft_watchdog" = 0;
|
|
|
|
"kernel.split_lock_mitigate" = 0;
|
|
|
|
"kernel.watchdog" = 0;
|
2024-10-20 11:46:59 -04:00
|
|
|
|
|
|
|
# Network optimizations
|
2024-10-20 01:46:11 -04:00
|
|
|
"net.core.default_qdisc" = "fq";
|
|
|
|
"net.ipv4.tcp_congestion_control" = "bbr";
|
2024-10-20 01:55:53 -04:00
|
|
|
"net.ipv4.tcp_mtu_probing" = lib.mkForce 1;
|
2024-10-20 11:46:59 -04:00
|
|
|
|
|
|
|
# Memory management
|
2024-10-20 01:46:11 -04:00
|
|
|
"vm.dirty_background_bytes" = 134217728;
|
|
|
|
"vm.dirty_bytes" = 268435456;
|
2024-10-20 01:55:53 -04:00
|
|
|
"vm.max_map_count" = lib.mkForce 2147483642;
|
2024-10-20 01:46:11 -04:00
|
|
|
"vm.page-cluster" = 0;
|
|
|
|
"vm.swappiness" = 180;
|
|
|
|
"vm.watermark_boost_factor" = 0;
|
|
|
|
"vm.watermark_scale_factor" = 125;
|
|
|
|
};
|
|
|
|
|
2024-10-20 11:46:59 -04:00
|
|
|
kernelModules = ["zenpower"]; # Improved temperature monitoring
|
|
|
|
|
|
|
|
# Xanmod seems more responsive under load
|
2024-10-14 23:53:48 -04:00
|
|
|
kernelPackages = lib.mkDefault pkgs.linuxPackages_xanmod_latest;
|
|
|
|
};
|
|
|
|
|
|
|
|
hardware = {
|
|
|
|
enableAllFirmware = true;
|
|
|
|
sensor.iio.enable = true;
|
|
|
|
};
|
|
|
|
|
2024-10-15 15:42:52 -04:00
|
|
|
services = {
|
|
|
|
pipewire.wireplumber.configPackages = [
|
|
|
|
(pkgs.writeTextDir "share/pipewire/pipewire.conf.d/10-legion-go-convolver.conf" ''
|
|
|
|
# Convolver Configuration for Pipewire
|
|
|
|
#
|
|
|
|
# This configuration applies separate left and right convolver effects using the corresponding impulse response files
|
|
|
|
# to the entire system audio output.
|
|
|
|
|
|
|
|
context.modules = [
|
|
|
|
{ name = libpipewire-module-filter-chain
|
|
|
|
args = {
|
|
|
|
node.description = "Legion Go"
|
|
|
|
media.name = "Legion Go"
|
|
|
|
filter.graph = {
|
|
|
|
nodes = [
|
|
|
|
{
|
|
|
|
type = builtin
|
|
|
|
label = convolver
|
|
|
|
name = convFL
|
|
|
|
config = {
|
|
|
|
filename = "${convolverPath}"
|
|
|
|
channel = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
type = builtin
|
|
|
|
label = convolver
|
|
|
|
name = convFR
|
|
|
|
config = {
|
|
|
|
filename = "${convolverPath}"
|
|
|
|
channel = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
inputs = [ "convFL:In" "convFR:In" ]
|
|
|
|
outputs = [ "convFL:Out" "convFR:Out" ]
|
|
|
|
}
|
|
|
|
capture.props = {
|
2024-10-15 18:08:38 -04:00
|
|
|
node.name = "Legion Go"
|
|
|
|
node.autoconnect = true
|
|
|
|
media.class = "Audio/Sink"
|
|
|
|
priority.driver = 1000
|
|
|
|
priority.session = 2000
|
|
|
|
audio.channels = 2
|
|
|
|
audio.position = [ FL FR ]
|
2024-10-15 15:42:52 -04:00
|
|
|
}
|
|
|
|
playback.props = {
|
|
|
|
node.name = "Legion Go corrected"
|
|
|
|
node.passive = true
|
|
|
|
audio.channels = 2
|
|
|
|
audio.position = [ FL FR ]
|
2024-10-15 18:08:38 -04:00
|
|
|
node.target = "alsa_output.pci-0000_c2_00.6.analog-stereo"
|
2024-10-15 15:42:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2024-10-19 23:36:38 -04:00
|
|
|
udev.extraRules = ''
|
2024-10-19 23:43:11 -04:00
|
|
|
# Lenovo Legion Go Controller
|
|
|
|
ACTION=="add", ATTRS{idVendor}=="17ef", ATTRS{idProduct}=="6182", RUN+="${pkgs.kmod}/bin/modprobe xpad" RUN+="/bin/sh -c 'echo 17ef 6182 > /sys/bus/usb/drivers/xpad/new_id'"
|
|
|
|
|
2024-10-20 11:46:59 -04:00
|
|
|
# Significantly improved I/O performance
|
|
|
|
## SSD
|
2024-10-19 23:36:38 -04:00
|
|
|
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="kyber"
|
2024-10-19 23:43:11 -04:00
|
|
|
|
2024-10-20 11:46:59 -04:00
|
|
|
## NVME
|
2024-10-19 23:36:38 -04:00
|
|
|
ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="kyber"
|
2024-10-19 23:43:11 -04:00
|
|
|
|
2024-10-20 11:46:59 -04:00
|
|
|
## MicroSD
|
2024-10-19 23:36:38 -04:00
|
|
|
ACTION=="add|change", KERNEL=="mmcblk[0-9]p[0-9]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq"
|
2024-10-19 23:43:11 -04:00
|
|
|
|
2024-10-20 11:46:59 -04:00
|
|
|
## HDD
|
2024-10-19 23:36:38 -04:00
|
|
|
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"
|
|
|
|
'';
|
|
|
|
|
2024-10-15 15:42:52 -04:00
|
|
|
upower.enable = true;
|
|
|
|
};
|
2024-10-14 23:53:48 -04:00
|
|
|
}
|