forked from
lass.pds.lassul.us/superconfig
This repository has no description
5.5 kB
120 lines
1{
2 self,
3 modulesPath,
4 pkgs,
5 ...
6}:
7{
8 imports = [
9 ./config.nix
10 (modulesPath + "/installer/scan/not-detected.nix")
11 ./disk.nix
12 self.inputs.nixos-hardware.nixosModules.framework-amd-ai-300-series
13 ];
14
15 services.fprintd.enable = true;
16 services.fwupd.enable = true;
17 services.fwupd.extraRemotes = [ "lvfs-testing" ];
18 # Might be necessary once to make the update succeed
19 # services.fwupd.uefiCapsuleSettings.DisableCapsuleUpdateOnDisk = true;
20 # we need fwupd 1.9.7 to downgrade the fingerprint sensor firmware
21 # we only need to downgrade the firmware once, so we can remove this once we have done that
22 # services.fwupd.package = (import (builtins.fetchTarball {
23 # url = "https://github.com/NixOS/nixpkgs/archive/bb2009ca185d97813e75736c2b8d1d8bb81bde05.tar.gz";
24 # sha256 = "sha256:003qcrsq5g5lggfrpq31gcvj82lb065xvr7bpfa8ddsw8x4dnysk";
25 # }) {
26 # inherit (pkgs) system;
27 # }).fwupd;
28
29 networking.hostId = "deadbeef";
30
31 boot.loader.grub = {
32 enable = true;
33 device = "/dev/nvme0n1";
34 efiSupport = true;
35 efiInstallAsRemovable = true;
36 # The ESP is only 1 GiB (see disk.nix); without a cap GRUB keeps every
37 # generation's kernel+initrd (~50-90 MiB each) until /boot fills and
38 # deploys fail. ~10 generations fits with headroom.
39 configurationLimit = 10;
40 };
41
42 hardware.graphics.enable = true;
43 hardware.acpilight.enable = true;
44 # DDC/CI: expose /dev/i2c-* so ddcutil can drive external monitor brightness
45 boot.kernelModules = [ "i2c-dev" ];
46
47 # Use latest kernel for better Strix Point GPU support. The MT7925 BT init
48 # regression fix (e3ac0d9f1a20) landed upstream in 7.0.10.
49 boot.kernelPackages = pkgs.linuxPackages_latest;
50
51 # MT7925 WiFi roam freezes (list_add corruption -> kernel BUG at
52 # lib/list_debug.c:32, 10 hard freezes 2026-07-03..07-07): generic
53 # mt76_sta_add() re-ran mt76_wcid_init() on a wcid the mt7925 sta_add
54 # had already published, so the rx/txs softirq could link it into
55 # sta_poll_list right before the second INIT_LIST_HEAD self-looped it.
56 # Fixed upstream in 7.1.3 by 20b126920a25 ("wifi: mt76: add wcid
57 # publish check in mt76_sta_add") - keep kernel >= 7.1.3.
58
59 # amdgpu.mes=0 (old RDNA3+ MES ring-hang workaround) was removed here:
60 # since kernel ~7.x the parameter no longer exists ("amdgpu: unknown
61 # parameter 'mes' ignored") and the GPU has been stable without it.
62
63 boot.initrd.availableKernelModules = [
64 "nvme"
65 "thunderbolt"
66 "xhci_pci"
67 "usbhid"
68 ];
69
70 # IO latency tuning. The whole system (/, /home, /nix) lives on one
71 # btrfs-on-LUKS-on-NVMe device, so bulk writes (downloads, builds) can starve
72 # latency-sensitive reads — e.g. launching a terminal stalls for seconds.
73 # Three independent causes, three fixes:
74
75 # 1. NVMe defaults to scheduler "none" (FIFO, no read/write fairness), so a
76 # read queues behind up to nr_requests (1023) writes. mq-deadline gives
77 # reads deadline priority over bulk writes.
78 services.udev.extraRules = ''
79 ACTION=="add|change", KERNEL=="nvme0n1", ATTR{queue/scheduler}="mq-deadline"
80 # ddcutil needs user access to the DP AUX i2c buses for DDC/CI
81 ACTION=="add|change", SUBSYSTEM=="i2c-dev", KERNEL=="i2c-*", MODE="0660", GROUP="i2c"
82 '';
83
84 # 2. Default dirty-page limits are ratio-based: ~6.2 GB background / ~12.4 GB
85 # hard on 62 GB RAM. Writes pool in RAM then flush in multi-GB bursts that
86 # flood the queue and freeze everything (PSI full IO). Small fixed byte
87 # limits make writeback continuous instead of bursty.
88 boot.kernel.sysctl."vm.dirty_bytes" = 268435456; # 256 MiB
89 boot.kernel.sysctl."vm.dirty_background_bytes" = 67108864; # 64 MiB
90
91 # 3. dm-crypt funnels all IO through the kcryptd workqueue, a serialization
92 # point under load. AES-NI is present so inline crypto is cheap — bypass
93 # the queues to cut crypt-layer latency. Device name from disk.nix.
94 boot.initrd.luks.devices.aergia1.bypassWorkqueues = true;
95
96 # MT7925 wifi stability. The dominant cause of the "drops every few
97 # minutes" was a dual-manager conflict (systemd-networkd AND NM both
98 # running DHCP on the wifi) - fixed in configs/network-manager.nix by
99 # handing wifi solely to NM. The remainder below addresses a *separate*,
100 # secondary mt7925 firmware bug: the card intermittently tears the link
101 # down during scans (wpa_supplicant "reason=3 locally_generated=1" next
102 # to "Reject scan trigger since one is already pending"; iwd shows it
103 # mid-roam) - a driver bug with no fix below the kernel. We need
104 # aggressive roaming (event with ~100 APs) so we cannot disable the scans
105 # that trigger it; we only cut how often it fires. When it does fire, NM
106 # re-associates on its own in a few seconds (a gateway-ping watchdog was
107 # tried and removed: bornhack's gateway drops ICMP, so it false-fired and
108 # bounced a working link every 90 s).
109 #
110 # 1. Stay on the default wpa_supplicant backend. iwd roams well but
111 # busy-loops at 100% CPU in this dense ~100-AP environment (it chokes
112 # on the flood of HE-capability beacons) and wedged the link hard
113 # enough to need a driver reload - not usable here.
114 #
115 # 2. Kill NIC power management. powersave and PCIe ASPM both let the
116 # firmware abort/miss a scan mid-connection on this chip; disabling
117 # both is the most-reported mt7925 stability mitigation.
118 networking.networkmanager.wifi.powersave = false;
119 boot.extraModprobeConfig = "options mt7925e disable_aspm=1";
120}