Skip to content

Commit 5871e21

Browse files
authored
screen-locker: add lockCmdEnv option (#6592)
1 parent c630dfa commit 5871e21

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

modules/services/screen-locker.nix

+9
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ in {
3131
example = "\${pkgs.i3lock}/bin/i3lock -n -c 000000";
3232
};
3333

34+
lockCmdEnv = lib.mkOption {
35+
type = types.listOf types.str;
36+
default = [ ];
37+
example = [ "XSECURELOCK_PAM_SERVICE=xsecurelock" ];
38+
description =
39+
"Environment variables to source a with the locker command (lockCmd).";
40+
};
41+
3442
inactiveInterval = mkOption {
3543
type = types.int;
3644
default = 10;
@@ -127,6 +135,7 @@ in {
127135
ExecStart = concatStringsSep " "
128136
([ "${cfg.xss-lock.package}/bin/xss-lock" "-s \${XDG_SESSION_ID}" ]
129137
++ cfg.xss-lock.extraOptions ++ [ "-- ${cfg.lockCmd}" ]);
138+
Environment = cfg.lockCmdEnv;
130139
Restart = "always";
131140
};
132141
};

tests/modules/services/screen-locker/basic-configuration.nix

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
enable = true;
66
inactiveInterval = 5;
77
lockCmd = "${pkgs.i3lock}/bin/i3lock -n -c AA0000";
8+
lockCmdEnv = [ "DISPLAY=:0" "XAUTHORITY=/custom/path/.Xauthority" ];
89
xss-lock = { extraOptions = [ "-test" ]; };
910
xautolock = {
1011
enable = true;
@@ -19,6 +20,8 @@
1920
2021
assertFileExists $xssService
2122
assertFileRegex $xssService 'ExecStart=.*/bin/xss-lock.*-test.*i3lock -n -c AA0000'
23+
assertFileRegex $xssService 'Environment=DISPLAY=:0'
24+
assertFileRegex $xssService 'Environment=XAUTHORITY=/custom/path/.Xauthority'
2225
assertFileRegex $xssService 'Restart=always'
2326
assertFileExists $xautolockService
2427
assertFileRegex $xautolockService 'ExecStart=.*/bin/xautolock.*-time 5.*-detectsleep.*-test.*'

tests/modules/services/screen-locker/moved-options.nix

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
enable = true;
66
inactiveInterval = 5;
77
lockCmd = "${pkgs.i3lock}/bin/i3lock -n -c AA0000";
8+
lockCmdEnv = [ "DISPLAY=:0" "XAUTHORITY=/custom/path/.Xauthority" ];
89
xssLockExtraOptions = [ "-test" ];
910
xautolockExtraOptions = [ "-test" ];
1011
enableDetectSleep = true;

0 commit comments

Comments
 (0)