Hello, I’ve been battling against this bug for quite a while now, and I think I’ve come to a solution, tho I’m not sure if this will work for everybody.
Recently I’ve noticed that when I’m logged out of any user I could suspend with no problem sometimes, but never when I was logged in, so I decided to do some testings:
First, suspend and wake up the computer from the login screen and record the journalctl output with journalctl > boot-ok.txt.
Second, log into a user and suspend, then force shutdown (cause the screen would be all black), boot up again, and record the output of the last boot from journalctl with journalctl --boot -1 > boot-not-ok.txt.
The first thing I’ve noticed was that when it failed I would get the following message:
jan 31 05:26:42 nixos systemd-sleep[27566]: Failed to freeze unit 'user.slice': Connection timed out
and when it worked the output was this
jan 31 00:16:40 nixos systemd-sleep[16380]: Successfully froze unit 'user.slice'.
After searching for a bit I found this issue [user session fails to resume from suspend when user is using NFS or KVM · Issue #33083 · systemd/systemd · GitHub] which suggest that adding this to systemd-suspend.service fixes their problems:
[Service]
Environment="SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false"
( overall the problem described in the issue seems unrelated, but the solution at face value looked like it would work for my problem )
so, after looking into how to edit systemd entries on nixos I came up with this
systemd.services."systemd-suspend" = {
serviceConfig = {
Environment=''"SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false"'';
};
};
And it seems to be working. I can suspend and wake up the computer while logged in with no problem. The only minor issue I’m having is that after waking up the screen will turn off again, but you just need to move your mouse around to turn it back on.
I hope this helps whoever comes across this post.