git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/xss-lock: add module (#40619)

`xsslock` (which was originally packaged in 6cb1d1aaaf02a72329bedf9c6960e54fea6f5c6e) 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"; } ```

commit641a62305305692c294ab3f67c597bc90067a667 authorMaximilian Bosch <maximilian@mbosch.me> dateFri 18 May 2018, 18:24 (9 years ago) parentcfc016c
4 files changed+53
nixos/modules/module-list.nix+1 nixos/modules/programs/xss-lock.nix+26 nixos/release.nix+1 nixos/tests/xss-lock.nix+25
nixos/modules/module-list.nix+1
@@ -122,6 +122,7 @@
122122 ./programs/wireshark.nix
123123 ./programs/xfs_quota.nix
124124 ./programs/xonsh.nix
125+ ./programs/xss-lock.nix
125126 ./programs/yabar.nix
126127 ./programs/zsh/oh-my-zsh.nix
127128 ./programs/zsh/zsh.nix
nixos/modules/programs/xss-lock.nixnew file+26
@@ -0,0 +1,26 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.programs.xss-lock;
7+in
8+{
9+ options.programs.xss-lock = {
10+ enable = mkEnableOption "xss-lock";
11+ lockerCommand = mkOption {
12+ example = "xlock";
13+ type = types.string;
14+ description = "Locker to be used with xsslock";
15+ };
16+ };
17+
18+ config = mkIf cfg.enable {
19+ systemd.user.services.xss-lock = {
20+ description = "XSS Lock Daemon";
21+ wantedBy = [ "graphical-session.target" ];
22+ partOf = [ "graphical-session.target" ];
23+ serviceConfig.ExecStart = "${pkgs.xss-lock}/bin/xss-lock ${cfg.lockerCommand}";
24+ };
25+ };
26+}
nixos/release.nix+1
@@ -402,6 +402,7 @@ in rec {
402402 tests.xfce = callTest tests/xfce.nix {};
403403 tests.xmonad = callTest tests/xmonad.nix {};
404404 tests.xrdp = callTest tests/xrdp.nix {};
405+ tests.xss-lock = callTest tests/xss-lock.nix {};
405406 tests.yabar = callTest tests/yabar.nix {};
406407 tests.zookeeper = callTest tests/zookeeper.nix {};
407408
nixos/tests/xss-lock.nixnew file+25
@@ -0,0 +1,25 @@
1+import ./make-test.nix ({ pkgs, lib, ... }:
2+
3+with lib;
4+
5+{
6+ name = "xss-lock";
7+ meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ma27 ];
8+
9+ machine = {
10+ imports = [ ./common/x11.nix ./common/user-account.nix ];
11+ programs.xss-lock.enable = true;
12+ programs.xss-lock.lockerCommand = "${pkgs.xlockmore}/bin/xlock";
13+ services.xserver.displayManager.auto.user = "alice";
14+ };
15+
16+ testScript = ''
17+ $machine->start;
18+ $machine->waitForX;
19+ $machine->waitForUnit("xss-lock.service", "alice");
20+
21+ $machine->fail("pgrep xlock");
22+ $machine->succeed("su -l alice -c 'xset dpms force standby'");
23+ $machine->succeed("pgrep xlock");
24+ '';
25+})