Paths in config.nix: systemctl is called by udev rules but not installed by udev

I have the following in my configuration.nix:

  services.udev.extraRules = ''
       RUN+="systemctl hibernate"

systemctl hibernate works manually but when I run nixos-rebuild switch I get the following error:

Checking that all programs called by absolute paths in udev rules exist… "

systemctl is called in udev rules but not installed by udev

What is the proper way to evoke systemctl in this case?


services.udev.extraRules = ‘’
RUN+=“systemctl hibernate”

RUN+="${pkgs.systemd}/bin/systemctl hibernate"

The absolute path should do the trick.

1 Like

You can use something like ${pkgs.systemd}/bin/systemctl.

1 Like

Thank you folks. I got the paths to work. However, this caused immediate suspend and then a bootloop, since selecting any generation would just bring up the suspended image and suspend again. I filed an issue here. How to do this properly? I am trying to trigger suspend on low battery. The above options work fine on Arch. I’ll post a new post for clarity since it is a different issue.