framework suspend fixes

This commit is contained in:
Julian Sutter 2025-11-26 21:01:51 -08:00
parent 88c207341f
commit 044e79b3c5
3 changed files with 63 additions and 122 deletions

View file

@ -118,6 +118,8 @@
util-linux # lsblk, lscpu
hwinfo # lsdev, lshal, hwinfo
lshw # lshw
nvme-cli
smartmontools
];
services.flatpak.enable = true;

View file

@ -10,50 +10,27 @@
fsType = "vfat";
};
# CPU Settings
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ "amdgpu" ];
boot.kernelModules = [ "kvm-amd" ]; # Include kvm-amd for virtualization support
boot.extraModulePackages = [];
boot.kernelParams = [
"amdgpu.dc=1"
"usbcore.autosuspend=-1"
"nvme_core.default_ps_max_latency_us=0"
"pcie_aspm=off" "pcie_port_pm=off"
"mem_sleep_default=s2idle"
];
services.power-profiles-daemon.enable = true;
services.tlp.enable = false;
services.thermald.enable = false; # thermald is for Intel, not AMD
networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
# Modified TLP for power management with less aggressive settings
# services.tlp = {
# enable = true;
# settings = {
# CPU_BOOST_ON_BAT = 0;
# CPU_SCALING_GOVERNOR_ON_BATTERY = "powersave";
# CPU_SCALING_GOVERNOR_ON_AC = "performance";
# CPU_ENERGY_PERF_POLICY_ON_AC = "balance_performance";
# START_CHARGE_THRESH_BAT0 = 90;
# STOP_CHARGE_THRESH_BAT0 = 97;
# RUNTIME_PM_ON_BAT = "on"; # Less aggressive power management
# HANDLE_LID_SWITCH = 1; # Suspend on lid close
# HANDLE_LID_SWITCH_DOCKED = 0; # Do nothing when docked
# Disable USB autosuspend
# USB_AUTOSUSPEND = 0;
# };
# };
# Powersac
# Swap
swapDevices = [
{
device = "/swapfile";
size = 102400;
# optional: set up file with correct permissions at activation
priority = 0;
}
];
@ -62,58 +39,20 @@
"f /swapfile 0600 root root - -"
];
# Disable power-profiles-daemon to resolve conflict
# services.power-profiles-daemon.enable = false;
# GPU settings
# services.xserver.videoDrivers = [ "amdgpu" ];
# environment.variables = {
# DRI_PRIME = "1"; # Ensure iGPU is default
# };
# Brightness control
hardware.acpilight.enable = lib.mkDefault true;
# SSD optimization
services.fstrim.enable = lib.mkDefault true;
# Logind lid-switch configuration
# services.logind = {
# lidSwitch = "suspend";
# lidSwitchDocked = "ignore"; # Prevent suspend when connected to a dock
# lidSwitchExternalPower = "ignore";
# powerKey = "poweroff"; # Optional: configure behavior for the power key
# suspendKey = "suspend"; # Optional: configure behavior for the suspend key
# };
# Suspend-then-hibernate configuration
# systemd.services.suspendThenHibernate = {
# description = "Suspend and then hibernate";
# after = [ "suspend.target" ];
# serviceConfig = {
# ExecStart = "/bin/sh -c 'sleep 3600 && systemctl hibernate'"; # Hibernate after 60 minutes
# Type = "oneshot";
# };
# wantedBy = [ "suspend.target" ];
# };
# Modified udev rules for runtime PM - disable problematic USB autosuspend
# services.udev.extraRules = ''
# ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"
# # ACTION=="add", SUBSYSTEM=="usb", ATTR{power/autosuspend}="10"
# '';
# ACPI lid event handler
# environment.etc."acpi/events/lid".source = pkgs.writeText "lid-event-handler" ''
# event=button/lid.*
# action=/etc/acpi/actions/lid.sh
# '';
# environment.etc."acpi/actions/lid.sh".source = pkgs.writeText "lid-sh-handler" ''
# #!/bin/bash
# systemctl suspend
# '';
# Logind lid-switch configuration
services.logind = {
lidSwitch = "suspend-then-hibernate";
lidSwitchDocked = "ignore"; # Prevent suspend when connected to a dock
lidSwitchExternalPower = "ignore";
powerKey = "poweroff";
suspendKey = "ignore"; # Optional: configure behavior for the suspend key
};
environment.systemPackages = with pkgs; [
via