nixos/services.physlock: remove with lib;
This commit is contained in:
parent
59dacf1e53
commit
ace688110e
@ -4,9 +4,6 @@
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.physlock;
|
||||
in
|
||||
@ -19,8 +16,8 @@ in
|
||||
|
||||
services.physlock = {
|
||||
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable the {command}`physlock` screen locking mechanism.
|
||||
@ -35,8 +32,8 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
allowAnyUser = mkOption {
|
||||
type = types.bool;
|
||||
allowAnyUser = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to allow any user to lock the screen. This will install a
|
||||
@ -46,24 +43,24 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
disableSysRq = mkOption {
|
||||
type = types.bool;
|
||||
disableSysRq = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to disable SysRq when locked with physlock.
|
||||
'';
|
||||
};
|
||||
|
||||
lockMessage = mkOption {
|
||||
type = types.str;
|
||||
lockMessage = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
description = ''
|
||||
Message to show on physlock login terminal.
|
||||
'';
|
||||
};
|
||||
|
||||
muteKernelMessages = mkOption {
|
||||
type = types.bool;
|
||||
muteKernelMessages = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Disable kernel messages on console while physlock is running.
|
||||
@ -72,24 +69,24 @@ in
|
||||
|
||||
lockOn = {
|
||||
|
||||
suspend = mkOption {
|
||||
type = types.bool;
|
||||
suspend = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to lock screen with physlock just before suspend.
|
||||
'';
|
||||
};
|
||||
|
||||
hibernate = mkOption {
|
||||
type = types.bool;
|
||||
hibernate = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to lock screen with physlock just before hibernate.
|
||||
'';
|
||||
};
|
||||
|
||||
extraTargets = mkOption {
|
||||
type = types.listOf types.str;
|
||||
extraTargets = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
example = [ "display-manager.service" ];
|
||||
description = ''
|
||||
@ -110,7 +107,7 @@ in
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
{
|
||||
|
||||
# for physlock -l and physlock -L
|
||||
@ -120,18 +117,18 @@ in
|
||||
enable = true;
|
||||
description = "Physlock";
|
||||
wantedBy =
|
||||
optional cfg.lockOn.suspend "suspend.target"
|
||||
++ optional cfg.lockOn.hibernate "hibernate.target"
|
||||
lib.optional cfg.lockOn.suspend "suspend.target"
|
||||
++ lib.optional cfg.lockOn.hibernate "hibernate.target"
|
||||
++ cfg.lockOn.extraTargets;
|
||||
before =
|
||||
optional cfg.lockOn.suspend "systemd-suspend.service"
|
||||
++ optional cfg.lockOn.hibernate "systemd-hibernate.service"
|
||||
++ optional (cfg.lockOn.hibernate || cfg.lockOn.suspend) "systemd-suspend-then-hibernate.service"
|
||||
lib.optional cfg.lockOn.suspend "systemd-suspend.service"
|
||||
++ lib.optional cfg.lockOn.hibernate "systemd-hibernate.service"
|
||||
++ lib.optional (cfg.lockOn.hibernate || cfg.lockOn.suspend) "systemd-suspend-then-hibernate.service"
|
||||
++ cfg.lockOn.extraTargets;
|
||||
serviceConfig = {
|
||||
Type = "forking";
|
||||
ExecStart = "${pkgs.physlock}/bin/physlock -d${optionalString cfg.muteKernelMessages "m"}${optionalString cfg.disableSysRq "s"}${
|
||||
optionalString (cfg.lockMessage != "") " -p \"${cfg.lockMessage}\""
|
||||
ExecStart = "${pkgs.physlock}/bin/physlock -d${lib.optionalString cfg.muteKernelMessages "m"}${lib.optionalString cfg.disableSysRq "s"}${
|
||||
lib.optionalString (cfg.lockMessage != "") " -p \"${cfg.lockMessage}\""
|
||||
}";
|
||||
};
|
||||
};
|
||||
@ -140,7 +137,7 @@ in
|
||||
|
||||
}
|
||||
|
||||
(mkIf cfg.allowAnyUser {
|
||||
(lib.mkIf cfg.allowAnyUser {
|
||||
|
||||
security.wrappers.physlock = {
|
||||
setuid = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user