initrd-boot-gui: Fail when LUKS is enabled but GUI disabled
{ config, lib, pkgs, ... }:
let
- inherit (lib) mkIf mkOption types;
+ inherit (lib) mkIf mkMerge mkOption types;
cfg = config.mobile.boot.stage-1.gui;
+ inherit (config.boot.initrd) luks;
minimalX11Config = pkgs.runCommand "minimalX11Config" {
allowedReferences = [ "out" ];
} ''
@@ -28,7 +29,19 @@ in
};
};
- config = mkIf cfg.enable {
+ 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 {
mobile.boot.stage-1.contents = with pkgs; [
{
object = "${pkgs.mobile-nixos.stage-1.boot-error}/libexec/boot-error.mrb";
@@ -52,5 +65,6 @@ in
XKB_CONFIG_ROOT = "/etc/X11/xkb";
XLOCALEDIR = "/etc/X11/locale";
};
- };
+ })
+ ]);
}
