Skip to content

fix: never suspend the appliance#25

Open
bpmct wants to merge 3 commits into
mainfrom
fix/disable-suspend
Open

fix: never suspend the appliance#25
bpmct wants to merge 3 commits into
mainfrom
fix/disable-suspend

Conversation

@bpmct

@bpmct bpmct commented Jun 15, 2026

Copy link
Copy Markdown
Member

The box is an always-on appliance (Coder server + k3s) reached over the LAN and a *.try.coder.app tunnel. A suspend drops the NIC, so the machine silently falls off the network — no mDNS, no SSH, tunnel dead — until someone physically wakes it.

The shipped image runs a KDE desktop (which exposes a Sleep action and reacts to the power key), and a stray systemctl suspend / Suspend() D-Bus call would do the same. This bit me: a box went unreachable, and the journal of the prior boot showed logind: The system will suspend now!Performing sleep operation 'suspend' with the NIC dropping its DHCP lease right after — a deliberate Suspend() via logind, not an idle timeout (it is a desktop chassis, no lid; logind idle defaults to ignore).

Fix

Mask the sleep targets so every suspend path (desktop Sleep, power key, systemctl suspend, Suspend() D-Bus) becomes a no-op, and tell logind to ignore the keys/idle:

systemd.targets.sleep.enable        = false;
systemd.targets.suspend.enable      = false;
systemd.targets.hibernate.enable    = false;
systemd.targets.hybrid-sleep.enable = false;
services.logind.settings.Login = {
  HandlePowerKey   = "ignore";
  HandleSuspendKey = "ignore";
  HandleLidSwitch  = "ignore";
  IdleAction       = "ignore";
};

This is hardening, not a fix for one specific trigger — an appliance simply should not be suspendable.

Validation

  • nixos-rebuild dry-build --flake /etc/nixos-repo emits unit-{sleep,suspend,hibernate,hybrid-sleep}.target-disabled and a rebuilt etc-systemd-logind.conf.

bpmct added 3 commits June 15, 2026 22:07
The box is an always-on appliance (Coder server + k3s) reached over the
LAN and a *.try.coder.app tunnel. A suspend drops the NIC, so the
machine silently falls off the network — no mDNS, no SSH, tunnel dead —
until someone physically wakes it.

The shipped image runs a KDE desktop (Sleep action + power-key handling)
and a stray `systemctl suspend` / Suspend() D-Bus call would do the
same. Mask the sleep/suspend/hibernate/hybrid-sleep targets so all of
those paths become no-ops, and set logind to ignore the power/suspend
keys and idle. Hardening, not a fix for one specific trigger — an
appliance simply should not be suspendable.

Verified with nixos-rebuild dry-build: emits
unit-{sleep,suspend,hibernate,hybrid-sleep}.target-disabled.
Drop the broad sleep/hibernate/hybrid-sleep target masking and the
power-key/lid/idle handlers. Block only suspend: mask suspend.target and
ignore the suspend key. The single concern is the appliance not
suspending itself off the network; everything else is left at defaults.

Verified with nixos-rebuild dry-build: emits unit-suspend.target-disabled.
Hibernate drops the NIC just like suspend, so block it too. Mask
suspend, hibernate, and hybrid-sleep targets and ignore the suspend/
hibernate keys. Idle/lid/power-key handling stays at NixOS defaults.

Verified with nixos-rebuild dry-build: emits
unit-{suspend,hibernate,hybrid-sleep}.target-disabled (sleep.target
itself is left enabled).
@bpmct bpmct requested a review from phorcys420 June 15, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant