NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.63k stars 13.78k forks source link

services.physlock.lockOn.extraTargets does not lock after startup #33168

Open magnetophon opened 6 years ago

magnetophon commented 6 years ago

Issue description

services.physlock.lockOn.extraTargets does not lock after startup when configured per the example in the help.

Steps to reproduce

With this config:

services.xserver.displayManager.lightdm = {
  enable = true;
  autoLogin.enable = true;
  autoLogin.user = "magnetophon";
};

services.physlock = {
  enable = true;
  lockOn = {
    suspend = true;
    hibernate = true;
    extraTargets = ["display-manager.service"];
  };

I get this error in systemctl status physlock.service:

systemd[1]: Starting Physlock...
physlock-start[774]: physlock: Unable to detect user of tty1

It does work when I use:

services.xserver.displayManager.slim = {
  enable = true;
  defaultUser = "bart";
  autoLogin = true;
  extraConfig = ''
    sessionstart_cmd    ${pkgs.physlock}/bin/physlock -ds
  '';
};

Technical details

 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.8, NixOS, 18.03pre123588.ade98dc442e (Impala)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 1.11.16`
 - channels(bart): `""`
 - channels(root): `"nixos-18.03pre123588.ade98dc442e"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs`
magnetophon commented 5 years ago

Any news on this? My workaround also stopped working: it boots me into a tty instead of X. When I remove the extraConfig, I get an X session.

magnetophon commented 4 years ago

I updated physlock to see if that fixed the problem. It didn't.

@oxij You wrote the code, any idea what's going on?

magnetophon commented 4 years ago

At the moment, physlock does lock, but it asks for the root password and it drops you in tty1 afterwards, instead of in your graphical session.

stale[bot] commented 4 years ago

Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on irc.freenode.net.
magnetophon commented 4 years ago

@oxij Any idea? Otherwise I'll close this.

oxij commented 4 years ago

systemd[1]: Starting Physlock... physlock-start[774]: physlock: Unable to detect user of tty1

That's a physlock issue, it should assume "root" as a user in this case, IMHO, but that's not the problem here.

The real problem is that the example code in nixos/modules/services/security/physlock.nix is incorrect (I never tested it, I just produced a seeming sane example from thin air) uses before attribute where in this case it should be setting "ExecStartPost=systemctl start physlock" in "display-manager.service" (as per systemd.service(5)) or something, which would do what you want and the example describes.

But clearly, that is not the ideal solution either, since "ExecStartPost" is an internal thing of the "display-manager.service" and could be used by other modules. Ideally, there would be a way to define systemd service which would be run after another service when that other service starts but systemd.unit(5) seems to say this is impossible:

Before=, After= These two settings expect a space-separated list of unit names. They configure ordering dependencies between units. If a unit foo.service contains a setting Before=bar.service and both units are being started, bar.service's start-up is delayed until foo.service has finished starting up.

To repeat:

both units are being started

So, I'd say this is a bug in documentation. Let's use another example, maybe?

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info