13

I'm using NixOS on a laptop and want to disable auto-suspension that happens every time I close the laptop lid. Approach described in “How to disable auto suspend when I close laptop lid?”, that is, editing /etc/systemd/logind.conf won't work, as it is just a symlink to /etc/static/systemd/logind.conf, which itself is a symlink to a file in /nix/store.

AFAIK, you shouldn't edit the Nix store directly, although I'm not entirely sure what would happen if I did. But the file in /nix/store doesn't have write permissions anyway.

How do I disable auto-suspension of a laptop in a NixOS idiomatic way?

2 Answers 2

16

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.

0
8

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";

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .