Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/xsslock: add module #40619

Merged
merged 1 commit into from May 18, 2018
Merged

nixos/xsslock: add module #40619

merged 1 commit into from May 18, 2018

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented May 16, 2018

Motivation for this change

xsslock (which was originally packaged in 6cb1d1a)
is a simple screensaver which connects a given screen locker (e.g.
i3lock) with logind. Whenever loginctl lock-sessions is invoked
the locker will be used to lock the screen. This works with its power
management features (e.g. lid switch) as well, so the PC can be locked
automatically when the lid is closed.

The module can be used like this:

{
  services.xserver.enable = true;

  programs.xss-lock.enable = true;
  programs.xss-lock.lockerCommand = "i3lock";
}
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Copy link
Contributor

@xeji xeji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module looks fine but the test should use a different approach.


$machine->fail("pgrep xlock");
$machine->systemctl("suspend");
$machine->sendKeys("a"); # wakeup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suspending the VM is quite fragile and non-deterministic. This test only works if the VM does not go fully into suspend yet by the time the keypress event arrives. Try sleep 5 in the perl script (not the VM) after the systemctl("suspend") : once the VM is really suspended, it doesn't come back, and the test is stuck.

As an alternative, try to activate xsslock using DPMS: $machine->succeed("xset dpms force standby"); instead of suspend and sendKeys. This will also activate the screen locker and should give you a reliable test.

`xsslock` (which was originally packaged in 6cb1d1a)
is a simple screensaver which connects a given screen locker (e.g.
`i3lock`) with `logind`. Whenever `loginctl lock-sessions` is invoked
the locker will be used to lock the screen. This works with its power
management features (e.g. `lid switch`) as well, so the PC can be locked
automatically when the lid is closed.

The module can be used like this:

```
{
  services.xserver.enable = true;

  programs.xss-lock.enable = true;
  programs.xss-lock.lockerCommand = "i3lock";
}
```
@Ma27
Copy link
Member Author

Ma27 commented May 18, 2018

you're right, dpms is the better solution, fixed it! %)

@xeji xeji merged commit 641a623 into NixOS:master May 18, 2018
@Ma27 Ma27 deleted the add-xss-lock-module branch May 18, 2018 16:25
@Ma27
Copy link
Member Author

Ma27 commented May 19, 2018

@xeji I'm very sorry for this, it seems as the test fails on Hydra: https://hydra.nixos.org/build/74427415
It seems as the assertion that the locker will be activated on standby doesn't work, unfortunately I'm absolutely unsure why this happens, do you have any idea? 😅

@xeji
Copy link
Contributor

xeji commented May 19, 2018

I cannot reproduce the error locally even under high load but the sequence of logged events is pretty much the same as on hydra. I guess it's a timing problem: xlock activation is delayed a little.
If my guess is correct, this will be fixed by changing the last line to
$machine->waitUntilSucceeds("pgrep xlock");
It's pretty much trial and error with these hydra-only failures.

Ma27 added a commit to Ma27/nixpkgs that referenced this pull request May 20, 2018
Please refer to the conversation in the original PR (NixOS#40619) for further
reference: NixOS#40619 (comment)

It takes some time after the standby to trigger the locker which might
break the test on Hydra.
xeji pushed a commit that referenced this pull request May 20, 2018
Please refer to the conversation in the original PR (#40619) for further
reference: #40619 (comment)

It takes some time after the standby to trigger the locker which might
break the test on Hydra.
globin pushed a commit to mayflower/nixpkgs that referenced this pull request May 24, 2018
`xsslock` (which was originally packaged in 6cb1d1a)
is a simple screensaver which connects a given screen locker (e.g.
`i3lock`) with `logind`. Whenever `loginctl lock-sessions` is invoked
the locker will be used to lock the screen. This works with its power
management features (e.g. `lid switch`) as well, so the PC can be locked
automatically when the lid is closed.

The module can be used like this:

```
{
  services.xserver.enable = true;

  programs.xss-lock.enable = true;
  programs.xss-lock.lockerCommand = "i3lock";
}
```

(cherry picked from commit 641a623)
@quantenzitrone
Copy link
Contributor

Shouldn't this be under services.xss-lock instead of programs.xss-lock?
I mean, it is basically just a wrapper for systemd.user.services.xss-lock...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants