···
1
+
{ config, lib, pkgs, ... }:
6
+
cfg = config.services.physlock;
15
+
services.physlock = {
21
+
Whether to enable the <command>physlock</command> screen locking mechanism.
23
+
Enable this and then run <command>systemctl start physlock</command>
24
+
to securely lock the screen.
26
+
This will switch to a new virtual terminal, turn off console
27
+
switching and disable SysRq mechanism (when
28
+
<option>services.physlock.disableSysRq</option> is set)
29
+
until the root or <option>services.physlock.user</option>
35
+
type = types.nullOr types.str;
38
+
User whose password will be used to unlock the screen on par
39
+
with the root password.
43
+
disableSysRq = mkOption {
47
+
Whether to disable SysRq when locked with physlock.
53
+
suspend = mkOption {
57
+
Whether to lock screen with physlock just before suspend.
61
+
hibernate = mkOption {
65
+
Whether to lock screen with physlock just before hibernate.
69
+
extraTargets = mkOption {
70
+
type = types.listOf types.str;
72
+
example = [ "display-manager.service" ];
74
+
Other targets to lock the screen just before.
76
+
Useful if you want to e.g. both autologin to X11 so that
77
+
your <filename>~/.xsession</filename> gets executed and
78
+
still to have the screen locked so that the system can be
79
+
booted relatively unattended.
90
+
###### implementation
92
+
config = mkIf cfg.enable {
94
+
# for physlock -l and physlock -L
95
+
environment.systemPackages = [ pkgs.physlock ];
97
+
systemd.services."physlock" = {
99
+
description = "Physlock";
100
+
wantedBy = optional cfg.lockOn.suspend "suspend.target"
101
+
++ optional cfg.lockOn.hibernate "hibernate.target"
102
+
++ cfg.lockOn.extraTargets;
103
+
before = optional cfg.lockOn.suspend "systemd-suspend.service"
104
+
++ optional cfg.lockOn.hibernate "systemd-hibernate.service"
105
+
++ cfg.lockOn.extraTargets;
106
+
serviceConfig.Type = "forking";
108
+
${pkgs.physlock}/bin/physlock -d${optionalString cfg.disableSysRq "s"}${optionalString (cfg.user != null) " -u ${cfg.user}"}