Xautolock isn't started

After having some weird problems with gnome flashback with i3 I decided to ditch it and I got back to i3 without a display manager. It works quite nicely, but I’m having problems with setting up locking. I have enabled physlock and xautolock (and xautolock is supposed to lock after 5 minutes inactivity), here’s my config:

  services.physlock = {
    enable = true;
    lockOn.suspend = true;
    lockOn.hibernate = true;
    allowAnyUser = true;
  };

  services.xserver.xautolock = {
    enable = true;
    enableNotifier = true;
    notifier = "${pkgs.libnotify}/bin/notify-send \"Locking in 10 seconds\"";
    time = 5;
    locker = "${pkgs.physlock}/bin/physlock";
  };

The problem is that xautolock doesn’t seem to be starting. When I try to do xautolock -locknow I get Could not locate a running xautolock.. I’ve tried removing extra options and leaving just services.xserver.xautolock.enabled = true, but it doesn’t seem to work either.

Any ideas on how to debug or fix it? Am I missing something?

I have been trying a bunch of things and couldn’t make xautolock work with the recommended config, so I I added a script that will start it in home manager:

  home.file.".bin/start-xautolock" = {
    text = ''
      ${pkgs.xautolock}/bin/xautolock -time 5 \
                -locker physlock \
                -notify 10 \
                -notifier "${pkgs.libnotify}/bin/notify-send \"Locking in 10 seconds\"" \
                -detectsleep

    '';
    executable = true;
  };

and then I added it to i3:

exec --no-startup-id ~/bin/start-xautolock

Before that I also tried adding it as a user systemd service (as it seems cleaner), but I have problems with using it with physlock, ie. it was executing the locker, but not doing anything. I suppose it might deal with setuid or something like that, but I didn’t have time to get into it deeper and the current config works fine.

Could try systemctl status xautolock.service or whatever it’s called. FWIW I am using xautolock from home-manager (so I’d debug it with systemctl status --user xautolock-session.service):

{ pkgs }:
let killall = "${pkgs.psmisc}/bin/killall";
in
{
  services.screen-locker = {
    enable = true;
    lockCmd = ''${pkgs.writeShellScript "lock-screen-dunst-i3lock" ''
      ${killall} -SIGUSR1 dunst # pause
      ( i3lock -n; ${killall} -SIGUSR2 dunst ) &
    ''}'';
    xautolockExtraOptions = [ "-corners" "----" ];
  };
}

Just for the record, I have

  services.physlock.enable = true;
  services.physlock.allowAnyUser = true;
  services.xserver.xautolock.enable = true;
  services.xserver.xautolock.locker = "/run/wrappers/bin/physlock";

in the system configuration, and it works extremely well! Physlock changes to the terminal, so even the keyboard layout is always constant :).