This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / machines / xerxes / physical.nix
4.8 kB 129 lines
1{ pkgs, ... }: 2{ 3 imports = [ 4 ./disk.nix 5 ./config.nix 6 ./gpd-fan.nix 7 ./gpd-win-mini-2025-pipewire.nix 8 ]; 9 boot.loader.systemd-boot.enable = true; 10 boot.loader.systemd-boot.configurationLimit = 10; 11 boot.loader.efi.canTouchEfiVariables = true; 12 boot.kernelPackages = pkgs.linuxPackages_latest; 13 hardware.graphics.enable = true; 14 15 # Load amdgpu early in initrd for reliable suspend/hibernate resume 16 hardware.amdgpu.initrd.enable = true; 17 18 # Disable Bluetooth USB autosuspend to prevent hardware errors/disconnects 19 # Disable VPE (Video Processing Engine) to fix black screen after suspend/resume 20 # on AMD Strix APUs. VPE fails to reset properly causing IB test timeouts. 21 # https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2065365 22 boot.extraModprobeConfig = '' 23 options btusb enable_autosuspend=0 24 options amdgpu ip_block_mask=0xfffff7ff 25 ''; 26 27 # Disable spurious wakeup sources that trigger immediate wake from s2idle 28 # - PCIe ports 29 # - USB host controllers (xhci_hcd) — external USB devices cause instant wakeup 30 # - Thunderbolt controllers 31 # - I2C touchpad/touchscreen (HTIX5288 via pinctrl_amd GPIO) 32 services.udev.extraRules = '' 33 ACTION=="add", SUBSYSTEM=="pci", DRIVER=="pcieport", ATTR{power/wakeup}="disabled" 34 ACTION=="add", SUBSYSTEM=="pci", DRIVER=="xhci_hcd", ATTR{power/wakeup}="disabled" 35 ACTION=="add", SUBSYSTEM=="pci", DRIVER=="thunderbolt", ATTR{power/wakeup}="disabled" 36 ACTION=="add", SUBSYSTEM=="i2c", ATTR{name}=="HTIX5288*", ATTR{power/wakeup}="disabled" 37 ACTION=="add", SUBSYSTEM=="serio", DRIVER=="atkbd", ATTR{power/wakeup}="disabled" 38 ''; 39 40 # Disable ACPI wakeup on USB/Thunderbolt controllers to prevent spurious wakeups 41 # (udev rules handle sysfs wakeup, this handles /proc/acpi/wakeup separately) 42 systemd.services.disable-acpi-wakeup = { 43 description = "Disable USB/Thunderbolt ACPI wakeup sources"; 44 wantedBy = [ "multi-user.target" ]; 45 after = [ "systemd-udev-settle.service" ]; 46 serviceConfig = { 47 Type = "oneshot"; 48 RemainAfterExit = true; 49 ExecStart = pkgs.writeShellScript "disable-acpi-wakeup" '' 50 for dev in XHC0 XHC1 XHC3 XHC4 NHI0 NHI1; do 51 if grep -q "^$dev.*enabled" /proc/acpi/wakeup; then 52 echo "$dev" > /proc/acpi/wakeup 53 fi 54 done 55 ''; 56 }; 57 }; 58 59 # Swapfile for hibernation (suspend-then-hibernate needs somewhere to dump RAM) 60 swapDevices = [ 61 { 62 device = "/swapfile"; 63 size = 65536; # 64GB to cover full RAM 64 } 65 ]; 66 67 # Resume from swapfile on the root partition 68 boot.resumeDevice = "/dev/disk/by-uuid/e2e38fb5-0cea-4a97-ae56-c2858ae0e07b"; 69 boot.kernelParams = [ 70 "resume_offset=156473344" 71 "amdgpu.gpu_recovery=1" # attempt GPU reset on failure instead of black screen 72 "amdgpu.dcdebugmask=0x10" # disable DSC to prevent GPU hang with external displays 73 ]; 74 75 # Pre-evict VRAM before sleep to prevent amdgpu resume black screen 76 # https://nyanpasu64.gitlab.io/blog/amdgpu-sleep-wake-hang/ 77 systemd.services.amdgpu-sleep = { 78 description = "Evict VRAM before sleep"; 79 before = [ 80 "sleep.target" 81 "suspend.target" 82 "hibernate.target" 83 "suspend-then-hibernate.target" 84 ]; 85 wantedBy = [ 86 "sleep.target" 87 "suspend.target" 88 "hibernate.target" 89 "suspend-then-hibernate.target" 90 ]; 91 unitConfig.StopWhenUnneeded = true; 92 serviceConfig = { 93 Type = "oneshot"; 94 RemainAfterExit = true; 95 ExecStart = "${pkgs.bash}/bin/bash -c 'for f in /sys/kernel/debug/dri/*/amdgpu_evict_vram; do cat \"$f\"; done'"; 96 }; 97 }; 98 99 # Unbind USB4/Thunderbolt controllers before sleep to allow s0ix deepest state 100 # AMD USB4 controllers stay active during s2idle and block entry into deepest sleep 101 # XHCI (USB3) controllers are left bound to avoid disconnecting gamepad/keyboard/mouse 102 environment.etc."systemd/system-sleep/usb4-sleep".source = pkgs.writeShellScript "usb4-sleep" '' 103 case "$1" in 104 pre) 105 for dev in 0000:c6:00.5 0000:c6:00.6; do 106 if [ -e /sys/bus/pci/drivers/thunderbolt/$dev ]; then 107 echo $dev > /sys/bus/pci/drivers/thunderbolt/unbind || true 108 fi 109 done 110 ;; 111 post) 112 for dev in 0000:c6:00.5 0000:c6:00.6; do 113 if [ ! -e /sys/bus/pci/drivers/thunderbolt/$dev ]; then 114 echo $dev > /sys/bus/pci/drivers/thunderbolt/bind || true 115 fi 116 done 117 ;; 118 esac 119 ''; 120 121 # s2idle for 15 minutes, then hibernate to save power 122 services.logind.powerKey = "suspend-then-hibernate"; 123 services.logind.lidSwitch = "suspend-then-hibernate"; 124 systemd.sleep.settings.Sleep = { 125 SuspendMode = "s2idle"; 126 SuspendState = "mem"; 127 HibernateDelaySec = "15min"; 128 }; 129}