How to disable suspend on close laptop lid on NixOS?

While the solution proposed by Mirzhan will probably work, there is a much more elegant way using the services.logind.lidSwitch and services.logind.lidSwitchDocked options.

Now, you can just write

services.logind.lidSwitch = "ignore";

These options also have types provided so an invalid configuration would be detected at build time.


There is a configuration option services.logind.extraConfig.

Open your NixOS configuration file (/etc/nixos/configuration.nix). Assign a string "HandleLidSwitch=ignore" (or whatever you would usually put into /etc/systemd/logind.conf) to that option:

services.logind.extraConfig = "HandleLidSwitch=ignore";