Why is my new NixOS install suspending?

I’ve just installed NixOS 22.05 from scratch on a server, and it keeps suspending (and crashing badly when resuming from suspend):

$ journalctl --boot=-1 --unit=systemd-suspend.service
Jun 03 23:04:04 lib systemd[1]: Starting System Suspend...
Jun 03 23:04:04 lib systemd-sleep[1632]: Entering sleep state 'suspend'...

It’s a server, so it should never suspend. I’ve disabled automatic suspend in the GNOME power settings, and the only suspension-related configuration I have is services.logind.extraConfig = "HandlePowerKey=suspend";. What else should I look for before reaching for the hack of just explicitly disabling the service? Also, is there some way to tell what activated the service?

1 Like

I’ve had similar problems with my server that has GNOME installed on it. Here’s some configuration I have on it:

  services.xserver.displayManager.gdm.autoSuspend = false;
  security.polkit.extraConfig = ''
    polkit.addRule(function(action, subject) {
        if (action.id == "org.freedesktop.login1.suspend" ||
            action.id == "org.freedesktop.login1.suspend-multiple-sessions" ||
            action.id == "org.freedesktop.login1.hibernate" ||
            action.id == "org.freedesktop.login1.hibernate-multiple-sessions")
        {
            return polkit.Result.NO;
        }
    });
  '';

You can look at Disabling gdm.autoSuspend still auto suspends · Issue #100390 · NixOS/nixpkgs · GitHub for some more details about this issue.

4 Likes

Thank you very much! I’ll give that a try. But why is that issue marked as resolved? Also, why would this only affect one of my several machines with NixOS 22.05?

That issue is specifically about

services.xserver.displayManager.gdm.autoSuspend = false;

which we could basically only resolve by improving the documentation, which we did.

It seems like it would be nice for there to be some general auto suspend option that turns everything else off though!

6 Likes

Welp, even with all those settings a similar issue persists on unstable right now: I keep getting warnings that my machine, while running on mains power, will be suspended. It never does suspend, but the spurious warning is annoying.

This seemed sufficient for me, together with:

dconf.settings = {  
  "org/gnome/settings-daemon/plugins/power" = {
    sleep-inactive-ac-type = "nothing";
  };
}

in a home manager module (which was not sufficient on its own).

However, given the implementation:

that seems pretty similar to the home manager configuration above, and the content of my dconf:

❯ dconf dump /org/gnome/settings-daemon/
[plugins/power]
sleep-inactive-ac-type='nothing'

I wonder how the first option affected the result… (and it did!)

EDIT: just to add more details: the home manager configs was sufficient after logging in a graphical session (while it was not otherwise)

2 Likes