Power Management
Suspend
Suspend hooks
NixOS provides the powerManagement.resumeCommands
option which defines commands that are added to a global script that will be executed after resuming.
powerManagement.resumeCommands = ''
echo "This should show up in the journal after resuming."
'';
It is also possible, to use the post-resume
target directly to make a service.
Refer to the Systemd Services article for details about writing systemd services for NixOS.
systemd.services.your-service-name = {
description = "Service description here";
wantedBy = [ "post-resume.target" ];
after = [ "post-resume.target" ];
script = ''
echo "This should show up in the journal after resuming."
'';
serviceConfig.Type = "oneshot";
};