2022-12-28 21:21:41 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.i3lock;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
programs.i3lock = {
|
2024-05-15 15:35:15 +00:00
|
|
|
enable = lib.mkEnableOption "i3lock";
|
|
|
|
package = lib.mkPackageOption pkgs "i3lock" {
|
2024-01-02 11:29:13 +00:00
|
|
|
example = "i3lock-color";
|
|
|
|
extraDescription = ''
|
|
|
|
::: {.note}
|
2022-12-28 21:21:41 +00:00
|
|
|
The i3lock package must include a i3lock file or link in its out directory in order for the u2fSupport option to work correctly.
|
2024-01-02 11:29:13 +00:00
|
|
|
:::
|
2022-12-28 21:21:41 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-05-15 15:35:15 +00:00
|
|
|
u2fSupport = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2022-12-28 21:21:41 +00:00
|
|
|
default = false;
|
|
|
|
example = true;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-12-28 21:21:41 +00:00
|
|
|
Whether to enable U2F support in the i3lock program.
|
|
|
|
U2F enables authentication using a hardware device, such as a security key.
|
|
|
|
When U2F support is enabled, the i3lock program will set the setuid bit on the i3lock binary and enable the pam u2fAuth service,
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2022-12-28 21:21:41 +00:00
|
|
|
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
security.wrappers.i3lock = lib.mkIf cfg.u2fSupport {
|
2022-12-28 21:21:41 +00:00
|
|
|
setuid = true;
|
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
source = "${cfg.package.out}/bin/i3lock";
|
|
|
|
};
|
|
|
|
|
|
|
|
security.pam.services.i3lock.u2fAuth = cfg.u2fSupport;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|