Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions named-hosts/matic/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ import ../../hosts/nixos {

# Power button behavior - lock screen instead of shutdown
services.logind.settings.Login.HandlePowerKey = "lock";
# Suspend on battery lid close; on AC, Hyprland locks on the lid switch event.
services.logind.settings.Login.HandleLidSwitch = "suspend";
# Hibernate on battery lid close; on AC, Hyprland locks on the lid switch event.
services.logind.settings.Login.HandleLidSwitch = "hibernate";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hibernate has no backing swap on this host. named-hosts/matic/hardware-configuration.nix:44 declares swapDevices = [ ], and there is no boot.resumeDevice, no swap file, and no resume=/resume_offset= entry in boot.kernelParams (see named-hosts/matic/default.nix:58-63) — grepping swap|resume|hibernat across named-hosts/matic/ and hosts/ returns only the fprintd-resume unit and this new line.

When systemd-logind receives the lid-close event it will call hibernate.target, which systemd refuses with Not enough swap space for hibernation / Sleep verb "hibernate" not supported. Net effect on battery: closing the lid does nothing — the machine stays awake in your bag. That's a regression from the previous suspend behavior and a real thermal/battery risk.

Fix direction: either revert to suspend (or suspend-then-hibernate), or land the hibernation prerequisites first — e.g. add a swap partition/file sized for RAM plus boot.resumeDevice = "/dev/disk/by-uuid/..." (and resume_offset if using a swap file), ideally on an encrypted volume separate from the TPM2-auto-unlocked root.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads-up on the security model: the root LUKS device auto-unlocks via TPM2 (named-hosts/matic/default.nix:44-47), which means whatever swap you end up putting the hibernation image on will also be transparently decrypted on next boot. If part of the motivation for moving to hibernate was "safer to leave the laptop shut for long periods," that's not really gained on this host versus suspend + LUKS — you'd want the hibernation swap on a separately-keyed encrypted volume (or bound to different PCRs / require a passphrase on resume) to get a real benefit. Latent today; becomes relevant the moment hibernation actually starts working.

services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore";

# Auto timezone (via geolocation)
Expand Down
6 changes: 3 additions & 3 deletions spec/matic_lid_policy_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Describe 'named-hosts/matic/default.nix lid policy'
CONFIG="$PWD/named-hosts/matic/default.nix"

It 'keeps battery lid close as suspend'
When run bash -c "grep -F 'services.logind.settings.Login.HandleLidSwitch = \"suspend\";' '$CONFIG'"
The output should include 'HandleLidSwitch = "suspend"'
It 'hibernates on battery lid close'
When run bash -c "grep -F 'services.logind.settings.Login.HandleLidSwitch = \"hibernate\";' '$CONFIG'"
The output should include 'HandleLidSwitch = "hibernate"'
End

It 'lets Hyprland handle lid close while on AC power'
Expand Down
Loading