From 044e79b3c5780fe0cbb0a59ede859dca6f38ad83 Mon Sep 17 00:00:00 2001 From: Julian Sutter Date: Wed, 26 Nov 2025 21:01:51 -0800 Subject: [PATCH] framework suspend fixes --- flake.lock | 96 +++++++++++++++++++++---------------------- systems/common.nix | 2 + systems/framework.nix | 87 ++++++--------------------------------- 3 files changed, 63 insertions(+), 122 deletions(-) diff --git a/flake.lock b/flake.lock index 35c450b..29ecca7 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ ] }, "locked": { - "lastModified": 1762356719, - "narHash": "sha256-qwd/xdoOya1m8FENle+4hWnydCtlXUWLAW/Auk6WL7s=", + "lastModified": 1763922789, + "narHash": "sha256-XnkWjCpeXfip9tqYdL0b0zzBDjq+dgdISvEdSVGdVyA=", "owner": "hyprwm", "repo": "aquamarine", - "rev": "6d0b3567584691bf9d8fedb5d0093309e2f979c7", + "rev": "a20a0e67a33b6848378a91b871b89588d3a12573", "type": "github" }, "original": { @@ -36,11 +36,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1747046372, - "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "lastModified": 1761588595, + "narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=", "owner": "edolstra", "repo": "flake-compat", - "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5", "type": "github" }, "original": { @@ -78,11 +78,11 @@ ] }, "locked": { - "lastModified": 1758463745, - "narHash": "sha256-uhzsV0Q0I9j2y/rfweWeGif5AWe0MGrgZ/3TjpDYdGA=", + "lastModified": 1763992789, + "narHash": "sha256-WHkdBlw6oyxXIra/vQPYLtqY+3G8dUVZM8bEXk0t8x4=", "owner": "nix-community", "repo": "home-manager", - "rev": "3b955f5f0a942f9f60cdc9cacb7844335d0f21c3", + "rev": "44831a7eaba4360fb81f2acc5ea6de5fde90aaa3", "type": "github" }, "original": { @@ -137,11 +137,11 @@ ] }, "locked": { - "lastModified": 1762462052, - "narHash": "sha256-6roLYzcDf4V38RUMSqycsOwAnqfodL6BmhRkUtwIgdA=", + "lastModified": 1763733840, + "narHash": "sha256-JnET78yl5RvpGuDQy3rCycOCkiKoLr5DN1fPhRNNMco=", "owner": "hyprwm", "repo": "hyprgraphics", - "rev": "ffc999d980c7b3bca85d3ebd0a9fbadf984a8162", + "rev": "8f1bec691b2d198c60cccabca7a94add2df4ed1a", "type": "github" }, "original": { @@ -166,11 +166,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1763819976, - "narHash": "sha256-W/893N/ifviI1PP1BVIwhYhstN8s5UOsi5lvaYupXhA=", + "lastModified": 1764195170, + "narHash": "sha256-04P/N4fVnBA/t/BPy/Q3HxFRxWyWjWv3CojzI1H1LMc=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "e584a8bade2617899d69ae6f83011d0c1d2a9df7", + "rev": "379ee99c681d45626604ad0253527438960ed374", "type": "github" }, "original": { @@ -212,11 +212,11 @@ ] }, "locked": { - "lastModified": 1762755186, - "narHash": "sha256-ZjjETUHtoEhVN7JI1Cbt3p/KcXpK8ZQaPHx7UkG1OgA=", + "lastModified": 1763727565, + "narHash": "sha256-vRff/2R1U1jzPBy4OODqh2kfUzmizW/nfV2ROzTDIKo=", "owner": "hyprwm", "repo": "hyprland-guiutils", - "rev": "66356e20a8ed348aa49c1b9ceace786e224225b3", + "rev": "7724d3a12a0453e7aae05f2ef39474219f05a4b4", "type": "github" }, "original": { @@ -266,11 +266,11 @@ ] }, "locked": { - "lastModified": 1763254292, - "narHash": "sha256-JNgz3Fz2KMzkT7aR72wsgu/xNeJB//LSmdilh8Z/Zao=", + "lastModified": 1763819661, + "narHash": "sha256-0jLarTR/BLWdGlboM86bPVP2zKJNI2jvo3JietnDkOM=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "deea98d5b61d066bdc7a68163edd2c4bd28d3a6b", + "rev": "a318deec0c12409ec39c68d2be8096b636dc2a5c", "type": "github" }, "original": { @@ -318,11 +318,11 @@ ] }, "locked": { - "lastModified": 1762463729, - "narHash": "sha256-2fYkU/mdz8WKY3dkDPlE/j6hTxIwqultsx4gMMsMns0=", + "lastModified": 1763503177, + "narHash": "sha256-VPoiswJBBmTLVuNncvT/8FpFR+sYcAi/LgP/zTZ+5rA=", "owner": "hyprwm", "repo": "hyprtoolkit", - "rev": "88483bdee5329ec985f0c8f834c519cd18cfe532", + "rev": "f4e1e12755567ecf39090203b8f43eace8279630", "type": "github" }, "original": { @@ -343,11 +343,11 @@ ] }, "locked": { - "lastModified": 1763323331, - "narHash": "sha256-+Z0OfCo1MS8/aIutSAW5aJR9zTae1wz9kcJYMgpwN6M=", + "lastModified": 1763996058, + "narHash": "sha256-DsqzFZvrEV+aDmavjaD4/bk5qxeZwhGxPWBQdpFyM9Y=", "owner": "hyprwm", "repo": "hyprutils", - "rev": "0c6411851cc779d551edc89b83966696201611aa", + "rev": "0168583075baffa083032ed13a8bea8ea12f281a", "type": "github" }, "original": { @@ -368,11 +368,11 @@ ] }, "locked": { - "lastModified": 1755184602, - "narHash": "sha256-RCBQN8xuADB0LEgaKbfRqwm6CdyopE1xIEhNc67FAbw=", + "lastModified": 1763640274, + "narHash": "sha256-Uan1Nl9i4TF/kyFoHnTq1bd/rsWh4GAK/9/jDqLbY5A=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "b3b0f1f40ae09d4447c20608e5a4faf8bf3c492d", + "rev": "f6cf414ca0e16a4d30198fd670ec86df3c89f671", "type": "github" }, "original": { @@ -383,11 +383,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1762847253, - "narHash": "sha256-BWWnUUT01lPwCWUvS0p6Px5UOBFeXJ8jR+ZdLX8IbrU=", + "lastModified": 1764080039, + "narHash": "sha256-b1MtLQsQc4Ji1u08f+C6g5XrmLPkJQ1fhNkCt+0AERQ=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "899dc449bc6428b9ee6b3b8f771ca2b0ef945ab9", + "rev": "da17006633ca9cda369be82893ae36824a2ddf1a", "type": "github" }, "original": { @@ -399,11 +399,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1763283776, - "narHash": "sha256-Y7TDFPK4GlqrKrivOcsHG8xSGqQx3A6c+i7novT85Uk=", + "lastModified": 1763966396, + "narHash": "sha256-6eeL1YPcY1MV3DDStIDIdy/zZCDKgHdkCmsrLJFiZf0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "50a96edd8d0db6cc8db57dab6bb6d6ee1f3dc49a", + "rev": "5ae3b07d8d6527c42f17c876e404993199144b6a", "type": "github" }, "original": { @@ -415,11 +415,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1763678758, - "narHash": "sha256-+hBiJ+kG5IoffUOdlANKFflTT5nO3FrrR2CA3178Y5s=", + "lastModified": 1763966396, + "narHash": "sha256-6eeL1YPcY1MV3DDStIDIdy/zZCDKgHdkCmsrLJFiZf0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "117cc7f94e8072499b0a7aa4c52084fa4e11cc9b", + "rev": "5ae3b07d8d6527c42f17c876e404993199144b6a", "type": "github" }, "original": { @@ -430,11 +430,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1763622513, - "narHash": "sha256-1jQnuyu82FpiSxowrF/iFK6Toh9BYprfDqfs4BB+19M=", + "lastModified": 1763948260, + "narHash": "sha256-dY9qLD0H0zOUgU3vWacPY6Qc421BeQAfm8kBuBtPVE0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c58bc7f5459328e4afac201c5c4feb7c818d604b", + "rev": "1c8ba8d3f7634acac4a2094eef7c32ad9106532c", "type": "github" }, "original": { @@ -453,11 +453,11 @@ ] }, "locked": { - "lastModified": 1762784320, - "narHash": "sha256-odsk96Erywk5hs0dhArF38zb7Oe0q6LZ70gXbxAPKno=", + "lastModified": 1763909441, + "narHash": "sha256-56LwV51TX/FhgX+5LCG6akQ5KrOWuKgcJa+eUsRMxsc=", "owner": "nix-community", "repo": "plasma-manager", - "rev": "7911a0f8a44c7e8b29d031be3149ee8943144321", + "rev": "b24ed4b272256dfc1cc2291f89a9821d5f9e14b4", "type": "github" }, "original": { @@ -476,11 +476,11 @@ ] }, "locked": { - "lastModified": 1763319842, - "narHash": "sha256-YG19IyrTdnVn0l3DvcUYm85u3PaqBt6tI6VvolcuHnA=", + "lastModified": 1763988335, + "narHash": "sha256-QlcnByMc8KBjpU37rbq5iP7Cp97HvjRP0ucfdh+M4Qc=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "7275fa67fbbb75891c16d9dee7d88e58aea2d761", + "rev": "50b9238891e388c9fdc6a5c49e49c42533a1b5ce", "type": "github" }, "original": { diff --git a/systems/common.nix b/systems/common.nix index dbaf97e..70d0fb2 100644 --- a/systems/common.nix +++ b/systems/common.nix @@ -118,6 +118,8 @@ util-linux # lsblk, lscpu hwinfo # lsdev, lshal, hwinfo lshw # lshw + nvme-cli + smartmontools ]; services.flatpak.enable = true; diff --git a/systems/framework.nix b/systems/framework.nix index e561501..13f12ae 100644 --- a/systems/framework.nix +++ b/systems/framework.nix @@ -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