at 25.11-pre 2.6 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.boot.initrd.unl0kr; 10 settingsFormat = pkgs.formats.ini { }; 11in 12{ 13 options.boot.initrd.unl0kr = { 14 enable = lib.mkEnableOption "unl0kr in initrd" // { 15 description = ''Whether to enable the unl0kr on-screen keyboard in initrd to unlock LUKS.''; 16 }; 17 18 package = lib.mkPackageOption pkgs "buffybox" { }; 19 20 allowVendorDrivers = lib.mkEnableOption "load optional drivers" // { 21 description = ''Whether to load additional drivers for certain vendors (I.E: Wacom, Intel, etc.)''; 22 }; 23 24 settings = lib.mkOption { 25 description = '' 26 Configuration for `unl0kr`. 27 28 See `unl0kr.conf(5)` for supported values. 29 30 Alternatively, visit `https://gitlab.postmarketos.org/postmarketOS/buffybox/-/blob/3.2.0/unl0kr/unl0kr.conf` 31 ''; 32 33 example = lib.literalExpression '' 34 { 35 general.animations = true; 36 general.backend = "drm"; 37 theme = { 38 default = "pmos-dark"; 39 alternate = "pmos-light"; 40 }; 41 } 42 ''; 43 default = { }; 44 type = lib.types.submodule { freeformType = settingsFormat.type; }; 45 }; 46 }; 47 48 config = lib.mkIf cfg.enable { 49 meta.maintainers = with lib.maintainers; [ hustlerone ]; 50 assertions = [ 51 { 52 assertion = cfg.enable -> config.boot.initrd.systemd.enable; 53 message = "boot.initrd.unl0kr is only supported with boot.initrd.systemd."; 54 } 55 ]; 56 57 warnings = lib.mkMerge [ 58 (lib.mkIf (config.hardware.amdgpu.initrd.enable) [ 59 ''Use early video loading at your risk. It's not guaranteed to work with unl0kr.'' 60 ]) 61 (lib.mkIf (config.boot.plymouth.enable) [ 62 ''Upstream clearly intends unl0kr to not run with Plymouth. Good luck'' 63 ]) 64 ]; 65 66 boot.initrd.availableKernelModules = 67 lib.optionals cfg.enable [ 68 "hid-multitouch" 69 "hid-generic" 70 "usbhid" 71 72 "i2c-designware-core" 73 "i2c-designware-platform" 74 "i2c-hid-acpi" 75 76 "usbtouchscreen" 77 "evdev" 78 "psmouse" 79 ] 80 ++ lib.optionals cfg.allowVendorDrivers [ 81 "intel_lpss_pci" 82 "elo" 83 "wacom" 84 ]; 85 86 boot.initrd.systemd = { 87 contents."/etc/unl0kr.conf".source = settingsFormat.generate "unl0kr.conf" cfg.settings; 88 storePaths = with pkgs; [ 89 libinput 90 xkeyboard_config 91 (lib.getExe' cfg.package "unl0kr") 92 "${cfg.package}/libexec/unl0kr-agent" 93 ]; 94 95 packages = [ 96 pkgs.buffybox 97 ]; 98 99 paths.unl0kr-agent.wantedBy = [ "local-fs-pre.target" ]; 100 }; 101 }; 102}