I have a nixos box that I am using as an HTPC. It works well except I can’t seem to stop it from going to sleep. It never did this with the previous Linux distro I had on the same hardware so I know I must be missing some configuration somewhere.
I tried setting powerManagement.enable = false; but that doesn’t seemed to have stopped it.
Are you using GNOME3 desktop? Then you might need this:
# Disable the GNOME3/GDM auto-suspend feature that cannot be disabled in GUI!
# If no user is logged in, the machine will power down after 20 minutes.
systemd.targets.sleep.enable = false;
systemd.targets.suspend.enable = false;
systemd.targets.hibernate.enable = false;
systemd.targets.hybrid-sleep.enable = false;
I also have this issue, I installed a Gnome desktop just using the graphical installer because I have a screen attached, but the box is actually a server. When I log into Gnome, I can set the box to never go to sleep using Gnome power management… But this setting is not applied when I don’t login (ie when I reboot and walk away), then the machine goes into standby. So I too need a way to prevent the system from ever sleeping.
If you disable sleep and hibernation on systemd level, you can encounter problem with GNOME trying to send the machine to sleep and turn on the screen.
Also after disabling them on systemd level, you cannot change GNOME settings in UI