Merge pull request #119974 from samueldr/feature/grub-gfx-aarch64
iso-image: Fix GRUB graphical menu on AArch64
This commit is contained in:
commit
385dc32fa8
|
@ -162,12 +162,14 @@ let
|
||||||
isolinuxCfg = concatStringsSep "\n"
|
isolinuxCfg = concatStringsSep "\n"
|
||||||
([ baseIsolinuxCfg ] ++ optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry);
|
([ baseIsolinuxCfg ] ++ optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry);
|
||||||
|
|
||||||
|
refindBinary = if targetArch == "x64" || targetArch == "aa64" then "refind_${targetArch}.efi" else null;
|
||||||
|
|
||||||
# Setup instructions for rEFInd.
|
# Setup instructions for rEFInd.
|
||||||
refind =
|
refind =
|
||||||
if targetArch == "x64" then
|
if refindBinary != null then
|
||||||
''
|
''
|
||||||
# Adds rEFInd to the ISO.
|
# Adds rEFInd to the ISO.
|
||||||
cp -v ${pkgs.refind}/share/refind/refind_x64.efi $out/EFI/boot/
|
cp -v ${pkgs.refind}/share/refind/${refindBinary} $out/EFI/boot/
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
"# No refind for ${targetArch}"
|
"# No refind for ${targetArch}"
|
||||||
|
@ -186,7 +188,10 @@ let
|
||||||
|
|
||||||
# Fonts can be loaded?
|
# Fonts can be loaded?
|
||||||
# (This font is assumed to always be provided as a fallback by NixOS)
|
# (This font is assumed to always be provided as a fallback by NixOS)
|
||||||
if loadfont (hd0)/EFI/boot/unicode.pf2; then
|
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.
|
# Use graphical term, it can be either with background image or a theme.
|
||||||
# input is "console", while output is "gfxterm".
|
# input is "console", while output is "gfxterm".
|
||||||
# This enables "serial" input and output only when possible.
|
# This enables "serial" input and output only when possible.
|
||||||
|
@ -207,11 +212,11 @@ let
|
||||||
${ # When there is a theme configured, use it, otherwise use the background image.
|
${ # When there is a theme configured, use it, otherwise use the background image.
|
||||||
if config.isoImage.grubTheme != null then ''
|
if config.isoImage.grubTheme != null then ''
|
||||||
# Sets theme.
|
# Sets theme.
|
||||||
set theme=(hd0)/EFI/boot/grub-theme/theme.txt
|
set theme=/EFI/boot/grub-theme/theme.txt
|
||||||
# Load theme fonts
|
# Load theme fonts
|
||||||
$(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont (hd0)/EFI/boot/grub-theme/%P\n")
|
$(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont /EFI/boot/grub-theme/%P\n")
|
||||||
'' else ''
|
'' else ''
|
||||||
if background_image (hd0)/EFI/boot/efi-background.png; then
|
if background_image /EFI/boot/efi-background.png; then
|
||||||
# Black background means transparent background when there
|
# Black background means transparent background when there
|
||||||
# is a background image set... This seems undocumented :(
|
# is a background image set... This seems undocumented :(
|
||||||
set color_normal=black/black
|
set color_normal=black/black
|
||||||
|
@ -264,6 +269,8 @@ let
|
||||||
|
|
||||||
cat <<EOF > $out/EFI/boot/grub.cfg
|
cat <<EOF > $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:
|
# If you want to use serial for "terminal_*" commands, you need to set one up:
|
||||||
# Example manual configuration:
|
# Example manual configuration:
|
||||||
# → serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
|
# → serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
|
||||||
|
@ -273,8 +280,28 @@ let
|
||||||
export with_serial
|
export with_serial
|
||||||
clear
|
clear
|
||||||
set timeout=10
|
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}
|
${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
|
# 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.
|
# line. We need this to allow the nixos iso to be booted from grub directly.
|
||||||
if [ \''${iso_path} ] ; then
|
if [ \''${iso_path} ] ; then
|
||||||
|
@ -337,11 +364,15 @@ let
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
menuentry 'rEFInd' --class refind {
|
${lib.optionalString (refindBinary != null) ''
|
||||||
# UUID is hard-coded in the derivation.
|
# GRUB apparently cannot do "chainloader" operations on "CD".
|
||||||
search --set=root --no-floppy --fs-uuid 1234-5678
|
if [ "\$root" != "cd0" ]; then
|
||||||
chainloader (\$root)/EFI/boot/refind_x64.efi
|
menuentry 'rEFInd' --class refind {
|
||||||
}
|
# \$root defaults to the drive the EFI is found on.
|
||||||
|
chainloader (\$root)/EFI/boot/${refindBinary}
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
''}
|
||||||
menuentry 'Firmware Setup' --class settings {
|
menuentry 'Firmware Setup' --class settings {
|
||||||
fwsetup
|
fwsetup
|
||||||
clear
|
clear
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
{ lib, stdenv, fetchgit, flex, bison, python3, autoconf, automake, gnulib, libtool
|
{ lib, stdenv, fetchgit, flex, bison, python3, autoconf, automake, gnulib, libtool
|
||||||
, gettext, ncurses, libusb-compat-0_1, freetype, qemu, lvm2, unifont, pkg-config
|
, gettext, ncurses, libusb-compat-0_1, freetype, qemu, lvm2, unifont, pkg-config
|
||||||
, buildPackages
|
, buildPackages
|
||||||
|
, fetchpatch
|
||||||
|
, pkgsBuildBuild
|
||||||
, nixosTests
|
, nixosTests
|
||||||
, fuse # only needed for grub-mount
|
, fuse # only needed for grub-mount
|
||||||
, runtimeShell
|
, runtimeShell
|
||||||
|
@ -55,6 +57,12 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
./fix-bash-completion.patch
|
./fix-bash-completion.patch
|
||||||
|
(fetchpatch {
|
||||||
|
name = "Add-hidden-menu-entries.patch";
|
||||||
|
# https://lists.gnu.org/archive/html/grub-devel/2016-04/msg00089.html
|
||||||
|
url = "https://marc.info/?l=grub-devel&m=146193404929072&q=mbox";
|
||||||
|
sha256 = "00wa1q5adiass6i0x7p98vynj9vsz1w0gn1g4dgz89v35mpyw2bi";
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
postPatch = if kbdcompSupport then ''
|
postPatch = if kbdcompSupport then ''
|
||||||
|
|
Loading…
Reference in New Issue