From 189507a35d4fd5c88e1172aee0a410229e60ba86 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Tue, 20 Apr 2021 01:34:15 -0400 Subject: iso-image: Make graphical output work properly on AArch64 The serial output (but it's named console, not serial actually) causes issues on U-Boot's EFI, at the very least. This is inspired by OpenSUSE's approach: * https://build.opensuse.org/package/view_file/Base:System/grub2/grub2-SUSE-Add-the-t-hotkey.patch Where they add a hidden menu entry, which can be used to force the console output. The `echo` will be visible on the serial terminal (grub "console"), while the graphical interface is shown. Note that input in the serial terminal (grub "console") will continue controlling the graphical interface. Useful if you have an SBC connectedinto an HDMI monitor, but no keyboard connected to it. --- nixos/modules/installer/cd-dvd/iso-image.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'nixos/modules/installer/cd-dvd') diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index e73bb883df5..b876e83e237 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -187,6 +187,9 @@ let # Fonts can be loaded? # (This font is assumed to always be provided as a fallback by NixOS) if loadfont /EFI/boot/unicode.pf2; then + set with_fonts=true + fi + if [ "\$textmode" != "true" -a "\$with_fonts" == "true" ]; then # Use graphical term, it can be either with background image or a theme. # input is "console", while output is "gfxterm". # This enables "serial" input and output only when possible. @@ -264,6 +267,8 @@ let cat < $out/EFI/boot/grub.cfg + set with_fonts=false + set textmode=false # If you want to use serial for "terminal_*" commands, you need to set one up: # Example manual configuration: # → serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 @@ -273,8 +278,28 @@ let export with_serial clear set timeout=10 + + # This message will only be viewable when "gfxterm" is not used. + echo "" + echo "Loading graphical boot menu..." + echo "" + echo "Press 't' to use the text boot menu on this console..." + echo "" + ${grubMenuCfg} + hiddenentry 'Text mode' --hotkey 't' { + loadfont /EFI/boot/unicode.pf2 + set textmode=true + terminal_output gfxterm console + } + hiddenentry 'GUI mode' --hotkey 'g' { + $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont /EFI/boot/grub-theme/%P\n") + set textmode=false + terminal_output gfxterm + } + + # If the parameter iso_path is set, append the findiso parameter to the kernel # line. We need this to allow the nixos iso to be booted from grub directly. if [ \''${iso_path} ] ; then -- cgit 1.4.1