2020-02-29 06:00:21 +03:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2022-10-01 04:52:42 +03:00
|
|
|
inherit (lib) mkIf mkMerge mkOption types;
|
2022-07-11 04:46:34 +03:00
|
|
|
cfg = config.mobile.boot.stage-1.gui;
|
2022-10-01 04:52:42 +03:00
|
|
|
inherit (config.boot.initrd) luks;
|
2022-09-27 06:42:22 +03:00
|
|
|
minimalX11Config = pkgs.runCommand "minimalX11Config" {
|
2020-11-21 03:23:16 +03:00
|
|
|
allowedReferences = [ "out" ];
|
|
|
|
} ''
|
|
|
|
(PS4=" $ "; set -x
|
|
|
|
mkdir -p $out
|
2022-03-09 19:02:56 +03:00
|
|
|
cp -r ${pkgs.xorg.xkeyboardconfig}/share/X11/xkb $out/xkb
|
|
|
|
cp -r ${pkgs.xorg.libX11.out}/share/X11/locale $out/locale
|
2020-11-21 03:23:16 +03:00
|
|
|
)
|
|
|
|
|
2022-03-09 19:02:56 +03:00
|
|
|
for f in $(grep -lIiR '${pkgs.xorg.libX11.out}' $out); do
|
2020-11-21 03:23:16 +03:00
|
|
|
printf ':: substituting original path for $out in "%s".\n' "$f"
|
|
|
|
substituteInPlace $f \
|
2022-03-09 19:02:56 +03:00
|
|
|
--replace "${pkgs.xorg.libX11.out}/share/X11/locale/en_US.UTF-8/Compose" "$out/locale/en_US.UTF-8/Compose"
|
2020-11-21 03:23:16 +03:00
|
|
|
done
|
|
|
|
'';
|
2020-02-29 06:00:21 +03:00
|
|
|
in
|
|
|
|
{
|
2022-07-11 04:46:34 +03:00
|
|
|
options.mobile.boot.stage-1.gui = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-03-15 08:34:48 +03:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
enable splash and boot selection GUI
|
|
|
|
'';
|
2022-07-11 04:46:34 +03:00
|
|
|
};
|
2023-03-03 18:32:47 +03:00
|
|
|
waitForDevices = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-03-15 08:02:25 +03:00
|
|
|
description = lib.mdDoc ''
|
2023-03-03 18:32:47 +03:00
|
|
|
Whether to wait a bit for input devices before starting the user interface.
|
|
|
|
|
|
|
|
This is only necessary on "slow" busses where devices may arrive a tad later than expected.
|
|
|
|
|
|
|
|
Generally, only enable when a device needed to input the passphrase is connected via USB.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
delay = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 2;
|
2023-03-15 08:02:25 +03:00
|
|
|
description = lib.mdDoc ''
|
2023-03-03 18:32:47 +03:00
|
|
|
Minimum delay spent waiting for input devices to settle.
|
|
|
|
|
|
|
|
The boot GUI will wait until this many seconds elapsed without changes before starting.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2022-07-11 04:46:34 +03:00
|
|
|
};
|
|
|
|
|
2022-10-01 04:52:42 +03:00
|
|
|
config = mkIf (config.mobile.boot.stage-1.enable) (mkMerge [
|
|
|
|
{
|
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
# When the Mobile NixOS stage-1 is in use, valid configurations are either:
|
|
|
|
# - GUI enabled (luks or not, don't care).
|
|
|
|
# - No LUKS.
|
|
|
|
assertion = cfg.enable || (luks.devices == {} && !luks.forceLuksSupportInInitrd);
|
|
|
|
message = "With the Mobile NixOS stage-1, the boot GUI needs to be enabled to use LUKS.";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
(mkIf cfg.enable {
|
2023-04-25 22:51:22 +03:00
|
|
|
mobile.boot.stage-1.contents = [
|
2022-10-01 04:52:42 +03:00
|
|
|
{
|
|
|
|
object = "${pkgs.mobile-nixos.stage-1.boot-error}/libexec/boot-error.mrb";
|
|
|
|
symlink = "/applets/boot-error.mrb";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
object = "${pkgs.mobile-nixos.stage-1.boot-splash}/libexec/boot-splash.mrb";
|
|
|
|
symlink = "/applets/boot-splash.mrb";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
object = "${pkgs.mobile-nixos.stage-1.boot-recovery-menu}/libexec/boot-recovery-menu.mrb";
|
|
|
|
symlink = "/applets/boot-selection.mrb";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
object = "${minimalX11Config}";
|
|
|
|
symlink = "/etc/X11";
|
|
|
|
}
|
|
|
|
];
|
2020-11-21 03:23:16 +03:00
|
|
|
|
2022-10-01 04:52:42 +03:00
|
|
|
mobile.boot.stage-1.environment = {
|
|
|
|
XKB_CONFIG_ROOT = "/etc/X11/xkb";
|
|
|
|
XLOCALEDIR = "/etc/X11/locale";
|
|
|
|
};
|
2023-03-03 18:32:47 +03:00
|
|
|
mobile.boot.stage-1.bootConfig = mkIf (cfg.waitForDevices.enable) {
|
|
|
|
quirks = {
|
|
|
|
wait_for_devices_delay = cfg.waitForDevices.delay;
|
|
|
|
};
|
|
|
|
};
|
2022-10-01 04:52:42 +03:00
|
|
|
})
|
|
|
|
]);
|
2020-02-29 06:00:21 +03:00
|
|
|
}
|