2024-09-06 18:14:53 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2023-02-27 00:30:19 +11:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.boot.initrd.unl0kr;
|
2024-09-06 18:14:53 +02:00
|
|
|
settingsFormat = pkgs.formats.ini { };
|
2023-02-27 00:30:19 +11:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.boot.initrd.unl0kr = {
|
|
|
|
enable = lib.mkEnableOption "unl0kr in initrd" // {
|
2024-09-06 18:14:53 +02:00
|
|
|
description = ''Whether to enable the unl0kr on-screen keyboard in initrd to unlock LUKS.'';
|
|
|
|
};
|
|
|
|
|
2024-12-07 21:02:05 +01:00
|
|
|
package = lib.mkPackageOption pkgs "buffybox" { };
|
2024-12-04 20:13:08 +00:00
|
|
|
|
2024-09-06 18:14:53 +02:00
|
|
|
allowVendorDrivers = lib.mkEnableOption "load optional drivers" // {
|
|
|
|
description = ''Whether to load additional drivers for certain vendors (I.E: Wacom, Intel, etc.)'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = lib.mkOption {
|
2023-02-27 00:30:19 +11:00
|
|
|
description = ''
|
2024-09-06 18:14:53 +02:00
|
|
|
Configuration for `unl0kr`.
|
|
|
|
|
|
|
|
See `unl0kr.conf(5)` for supported values.
|
|
|
|
|
2024-12-07 21:02:05 +01:00
|
|
|
Alternatively, visit `https://gitlab.postmarketos.org/postmarketOS/buffybox/-/blob/3.2.0/unl0kr/unl0kr.conf`
|
2023-02-27 00:30:19 +11:00
|
|
|
'';
|
2024-09-06 18:14:53 +02:00
|
|
|
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
{
|
2024-10-31 02:52:33 +01:00
|
|
|
general.animations = true;
|
2024-12-07 21:02:05 +01:00
|
|
|
general.backend = "drm";
|
2024-10-31 02:52:33 +01:00
|
|
|
theme = {
|
|
|
|
default = "pmos-dark";
|
|
|
|
alternate = "pmos-light";
|
|
|
|
};
|
2024-09-06 18:14:53 +02:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
default = { };
|
|
|
|
type = lib.types.submodule { freeformType = settingsFormat.type; };
|
2023-02-27 00:30:19 +11:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2024-09-06 18:14:53 +02:00
|
|
|
meta.maintainers = with lib.maintainers; [ hustlerone ];
|
2023-02-27 00:30:19 +11:00
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = cfg.enable -> config.boot.initrd.systemd.enable;
|
|
|
|
message = "boot.initrd.unl0kr is only supported with boot.initrd.systemd.";
|
|
|
|
}
|
2024-12-07 21:02:05 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
warnings = lib.mkMerge [
|
|
|
|
(lib.mkIf (config.hardware.amdgpu.initrd.enable) [
|
|
|
|
''Use early video loading at your risk. It's not guaranteed to work with unl0kr.''
|
|
|
|
])
|
|
|
|
(lib.mkIf (config.boot.plymouth.enable) [
|
|
|
|
''Upstream clearly intends unl0kr to not run with Plymouth. Good luck''
|
|
|
|
])
|
2023-02-27 00:30:19 +11:00
|
|
|
];
|
|
|
|
|
2024-09-06 18:14:53 +02:00
|
|
|
boot.initrd.availableKernelModules =
|
|
|
|
lib.optionals cfg.enable [
|
|
|
|
"hid-multitouch"
|
|
|
|
"hid-generic"
|
|
|
|
"usbhid"
|
|
|
|
|
|
|
|
"i2c-designware-core"
|
|
|
|
"i2c-designware-platform"
|
|
|
|
"i2c-hid-acpi"
|
|
|
|
|
|
|
|
"usbtouchscreen"
|
|
|
|
"evdev"
|
2025-05-09 00:29:43 +02:00
|
|
|
"psmouse"
|
2024-09-06 18:14:53 +02:00
|
|
|
]
|
|
|
|
++ lib.optionals cfg.allowVendorDrivers [
|
|
|
|
"intel_lpss_pci"
|
|
|
|
"elo"
|
|
|
|
"wacom"
|
|
|
|
];
|
|
|
|
|
2023-02-27 00:30:19 +11:00
|
|
|
boot.initrd.systemd = {
|
2024-09-06 18:14:53 +02:00
|
|
|
contents."/etc/unl0kr.conf".source = settingsFormat.generate "unl0kr.conf" cfg.settings;
|
2023-02-27 00:30:19 +11:00
|
|
|
storePaths = with pkgs; [
|
|
|
|
libinput
|
|
|
|
xkeyboard_config
|
2024-12-04 20:13:08 +00:00
|
|
|
(lib.getExe' cfg.package "unl0kr")
|
2024-12-07 21:02:05 +01:00
|
|
|
"${cfg.package}/libexec/unl0kr-agent"
|
2023-02-27 00:30:19 +11:00
|
|
|
];
|
|
|
|
|
2024-12-07 21:02:05 +01:00
|
|
|
packages = [
|
|
|
|
pkgs.buffybox
|
|
|
|
];
|
2023-02-27 00:30:19 +11:00
|
|
|
|
2024-12-07 21:02:05 +01:00
|
|
|
paths.unl0kr-agent.wantedBy = [ "local-fs-pre.target" ];
|
2023-02-27 00:30:19 +11:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|