3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/modules/programs/xss-lock.nix
Even Brenden 660882d883 nixos/displayManager: add XDG_SESSION_ID to systemd user environment
xss-lock needs XDG_SESSION_ID to respond to loginctl lock-session(s)
(and possibly other session operations such as idle hint management).
This change adds XDG_SESSION_ID to the list of imported environment
variables when starting systemctl.

Inspired by home-manager, add importVariables configuration.

Set session to XDG_SESSION_ID when running xss-lock as a service.

Co-authored-by: misuzu <bakalolka@gmail.com>
2020-09-05 20:36:18 +02:00

45 lines
1.1 KiB
Nix

{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.programs.xss-lock;
in
{
options.programs.xss-lock = {
enable = mkEnableOption "xss-lock";
lockerCommand = mkOption {
default = "${pkgs.i3lock}/bin/i3lock";
example = literalExample ''''${pkgs.i3lock-fancy}/bin/i3lock-fancy'';
type = types.separatedString " ";
description = "Locker to be used with xsslock";
};
extraOptions = mkOption {
default = [ ];
example = [ "--ignore-sleep" ];
type = types.listOf types.str;
description = ''
Additional command-line arguments to pass to
<command>xss-lock</command>.
'';
};
};
config = mkIf cfg.enable {
systemd.user.services.xss-lock = {
description = "XSS Lock Daemon";
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
serviceConfig.ExecStart = with lib;
strings.concatStringsSep " " ([
"${pkgs.xss-lock}/bin/xss-lock" "--session \${XDG_SESSION_ID}"
] ++ (map escapeShellArg cfg.extraOptions) ++ [
"--"
cfg.lockerCommand
]);
};
};
}