diff --git a/modules/services/screen-locker.nix b/modules/services/screen-locker.nix index 0ec9ba528..3e2b14b11 100644 --- a/modules/services/screen-locker.nix +++ b/modules/services/screen-locker.nix @@ -31,6 +31,14 @@ in { example = "\${pkgs.i3lock}/bin/i3lock -n -c 000000"; }; + lockCmdEnv = lib.mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "XSECURELOCK_PAM_SERVICE=xsecurelock" ]; + description = + "Environment variables to source a with the locker command (lockCmd)."; + }; + inactiveInterval = mkOption { type = types.int; default = 10; @@ -127,6 +135,7 @@ in { ExecStart = concatStringsSep " " ([ "${cfg.xss-lock.package}/bin/xss-lock" "-s \${XDG_SESSION_ID}" ] ++ cfg.xss-lock.extraOptions ++ [ "-- ${cfg.lockCmd}" ]); + Environment = cfg.lockCmdEnv; Restart = "always"; }; }; diff --git a/tests/modules/services/screen-locker/basic-configuration.nix b/tests/modules/services/screen-locker/basic-configuration.nix index e92a4a9f1..1cf4fabe2 100644 --- a/tests/modules/services/screen-locker/basic-configuration.nix +++ b/tests/modules/services/screen-locker/basic-configuration.nix @@ -5,6 +5,7 @@ enable = true; inactiveInterval = 5; lockCmd = "${pkgs.i3lock}/bin/i3lock -n -c AA0000"; + lockCmdEnv = [ "DISPLAY=:0" "XAUTHORITY=/custom/path/.Xauthority" ]; xss-lock = { extraOptions = [ "-test" ]; }; xautolock = { enable = true; @@ -19,6 +20,8 @@ assertFileExists $xssService assertFileRegex $xssService 'ExecStart=.*/bin/xss-lock.*-test.*i3lock -n -c AA0000' + assertFileRegex $xssService 'Environment=DISPLAY=:0' + assertFileRegex $xssService 'Environment=XAUTHORITY=/custom/path/.Xauthority' assertFileRegex $xssService 'Restart=always' assertFileExists $xautolockService assertFileRegex $xautolockService 'ExecStart=.*/bin/xautolock.*-time 5.*-detectsleep.*-test.*' diff --git a/tests/modules/services/screen-locker/moved-options.nix b/tests/modules/services/screen-locker/moved-options.nix index 0f252a1d3..bb49b0489 100644 --- a/tests/modules/services/screen-locker/moved-options.nix +++ b/tests/modules/services/screen-locker/moved-options.nix @@ -5,6 +5,7 @@ enable = true; inactiveInterval = 5; lockCmd = "${pkgs.i3lock}/bin/i3lock -n -c AA0000"; + lockCmdEnv = [ "DISPLAY=:0" "XAUTHORITY=/custom/path/.Xauthority" ]; xssLockExtraOptions = [ "-test" ]; xautolockExtraOptions = [ "-test" ]; enableDetectSleep = true;