Prevent laptop from suspending when lid is closed if on AC

Before I go and implement this myself, does anyone happen to have a nixos module in their config that configures their laptop such that it does not suspend when the lid is closed if it is on AC wall power?

This looks like a pretty clear description of how to do it, which could be adapted for NixOS: Prevent suspend on lid close with systemd – nrocco.github.io, but if anyone’s already done the work, I’d love to steal your work.

1 Like

I think this should work: https://nixos.org/manual/nixos/stable/options.html#opt-services.logind.lidSwitchExternalPower

services.logind.lidSwitchExternalPower = "ignore";
4 Likes

Brilliant!! Thank you for pointing me to that.