1{ config, pkgs, lib, ... }:
2
3let
4 cfg = config.programs.xss-lock;
5in
6{
7 options.programs.xss-lock = {
8 enable = lib.mkEnableOption "xss-lock";
9
10 lockerCommand = lib.mkOption {
11 default = "${pkgs.i3lock}/bin/i3lock";
12 defaultText = lib.literalExpression ''"''${pkgs.i3lock}/bin/i3lock"'';
13 example = lib.literalExpression ''"''${pkgs.i3lock-fancy}/bin/i3lock-fancy"'';
14 type = lib.types.separatedString " ";
15 description = "Locker to be used with xsslock";
16 };
17
18 extraOptions = lib.mkOption {
19 default = [ ];
20 example = [ "--ignore-sleep" ];
21 type = lib.types.listOf lib.types.str;
22 description = ''
23 Additional command-line arguments to pass to
24 {command}`xss-lock`.
25 '';
26 };
27 };
28
29 config = lib.mkIf cfg.enable {
30 systemd.user.services.xss-lock = {
31 description = "XSS Lock Daemon";
32 wantedBy = [ "graphical-session.target" ];
33 partOf = [ "graphical-session.target" ];
34 serviceConfig.ExecStart =
35 builtins.concatStringsSep " " ([
36 "${pkgs.xss-lock}/bin/xss-lock" "--session \${XDG_SESSION_ID}"
37 ] ++ (builtins.map lib.escapeShellArg cfg.extraOptions) ++ [
38 "--"
39 cfg.lockerCommand
40 ]);
41 serviceConfig.Restart = "always";
42 };
43
44 warnings = lib.mkIf (config.services.xserver.displayManager.startx.enable) [
45 "xss-lock service only works if a displayManager is set; it doesn't work when services.xserver.displayManager.startx.enable = true"
46 ];
47
48 };
49}