Merge pull request #119974 from samueldr/feature/grub-gfx-aarch64

iso-image: Fix GRUB graphical menu on AArch64

authored by

Samuel Dionne-Riel and committed by
GitHub
385dc32f 54d0d2b4

+50 -11
+42 -11
nixos/modules/installer/cd-dvd/iso-image.nix
··· 162 isolinuxCfg = concatStringsSep "\n" 163 ([ baseIsolinuxCfg ] ++ optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry); 164 165 # Setup instructions for rEFInd. 166 refind = 167 - if targetArch == "x64" then 168 '' 169 # Adds rEFInd to the ISO. 170 - cp -v ${pkgs.refind}/share/refind/refind_x64.efi $out/EFI/boot/ 171 '' 172 else 173 "# No refind for ${targetArch}" ··· 186 187 # Fonts can be loaded? 188 # (This font is assumed to always be provided as a fallback by NixOS) 189 - if loadfont (hd0)/EFI/boot/unicode.pf2; then 190 # Use graphical term, it can be either with background image or a theme. 191 # input is "console", while output is "gfxterm". 192 # This enables "serial" input and output only when possible. ··· 207 ${ # When there is a theme configured, use it, otherwise use the background image. 208 if config.isoImage.grubTheme != null then '' 209 # Sets theme. 210 - set theme=(hd0)/EFI/boot/grub-theme/theme.txt 211 # Load theme fonts 212 - $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont (hd0)/EFI/boot/grub-theme/%P\n") 213 '' else '' 214 - if background_image (hd0)/EFI/boot/efi-background.png; then 215 # Black background means transparent background when there 216 # is a background image set... This seems undocumented :( 217 set color_normal=black/black ··· 264 265 cat <<EOF > $out/EFI/boot/grub.cfg 266 267 # If you want to use serial for "terminal_*" commands, you need to set one up: 268 # Example manual configuration: 269 # → serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 ··· 273 export with_serial 274 clear 275 set timeout=10 276 ${grubMenuCfg} 277 278 # If the parameter iso_path is set, append the findiso parameter to the kernel 279 # line. We need this to allow the nixos iso to be booted from grub directly. 280 if [ \''${iso_path} ] ; then ··· 337 } 338 } 339 340 - menuentry 'rEFInd' --class refind { 341 - # UUID is hard-coded in the derivation. 342 - search --set=root --no-floppy --fs-uuid 1234-5678 343 - chainloader (\$root)/EFI/boot/refind_x64.efi 344 - } 345 menuentry 'Firmware Setup' --class settings { 346 fwsetup 347 clear
··· 162 isolinuxCfg = concatStringsSep "\n" 163 ([ baseIsolinuxCfg ] ++ optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry); 164 165 + refindBinary = if targetArch == "x64" || targetArch == "aa64" then "refind_${targetArch}.efi" else null; 166 + 167 # Setup instructions for rEFInd. 168 refind = 169 + if refindBinary != null then 170 '' 171 # Adds rEFInd to the ISO. 172 + cp -v ${pkgs.refind}/share/refind/${refindBinary} $out/EFI/boot/ 173 '' 174 else 175 "# No refind for ${targetArch}" ··· 188 189 # Fonts can be loaded? 190 # (This font is assumed to always be provided as a fallback by NixOS) 191 + if loadfont /EFI/boot/unicode.pf2; then 192 + set with_fonts=true 193 + fi 194 + if [ "\$textmode" != "true" -a "\$with_fonts" == "true" ]; then 195 # Use graphical term, it can be either with background image or a theme. 196 # input is "console", while output is "gfxterm". 197 # This enables "serial" input and output only when possible. ··· 212 ${ # When there is a theme configured, use it, otherwise use the background image. 213 if config.isoImage.grubTheme != null then '' 214 # Sets theme. 215 + set theme=/EFI/boot/grub-theme/theme.txt 216 # Load theme fonts 217 + $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont /EFI/boot/grub-theme/%P\n") 218 '' else '' 219 + if background_image /EFI/boot/efi-background.png; then 220 # Black background means transparent background when there 221 # is a background image set... This seems undocumented :( 222 set color_normal=black/black ··· 269 270 cat <<EOF > $out/EFI/boot/grub.cfg 271 272 + set with_fonts=false 273 + set textmode=false 274 # If you want to use serial for "terminal_*" commands, you need to set one up: 275 # Example manual configuration: 276 # → serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 ··· 280 export with_serial 281 clear 282 set timeout=10 283 + 284 + # This message will only be viewable when "gfxterm" is not used. 285 + echo "" 286 + echo "Loading graphical boot menu..." 287 + echo "" 288 + echo "Press 't' to use the text boot menu on this console..." 289 + echo "" 290 + 291 ${grubMenuCfg} 292 293 + hiddenentry 'Text mode' --hotkey 't' { 294 + loadfont /EFI/boot/unicode.pf2 295 + set textmode=true 296 + terminal_output gfxterm console 297 + } 298 + hiddenentry 'GUI mode' --hotkey 'g' { 299 + $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont /EFI/boot/grub-theme/%P\n") 300 + set textmode=false 301 + terminal_output gfxterm 302 + } 303 + 304 + 305 # If the parameter iso_path is set, append the findiso parameter to the kernel 306 # line. We need this to allow the nixos iso to be booted from grub directly. 307 if [ \''${iso_path} ] ; then ··· 364 } 365 } 366 367 + ${lib.optionalString (refindBinary != null) '' 368 + # GRUB apparently cannot do "chainloader" operations on "CD". 369 + if [ "\$root" != "cd0" ]; then 370 + menuentry 'rEFInd' --class refind { 371 + # \$root defaults to the drive the EFI is found on. 372 + chainloader (\$root)/EFI/boot/${refindBinary} 373 + } 374 + fi 375 + ''} 376 menuentry 'Firmware Setup' --class settings { 377 fwsetup 378 clear
+8
pkgs/tools/misc/grub/2.0x.nix
··· 1 { lib, stdenv, fetchgit, flex, bison, python3, autoconf, automake, gnulib, libtool 2 , gettext, ncurses, libusb-compat-0_1, freetype, qemu, lvm2, unifont, pkg-config 3 , buildPackages 4 , nixosTests 5 , fuse # only needed for grub-mount 6 , runtimeShell ··· 55 56 patches = [ 57 ./fix-bash-completion.patch 58 ]; 59 60 postPatch = if kbdcompSupport then ''
··· 1 { lib, stdenv, fetchgit, flex, bison, python3, autoconf, automake, gnulib, libtool 2 , gettext, ncurses, libusb-compat-0_1, freetype, qemu, lvm2, unifont, pkg-config 3 , buildPackages 4 + , fetchpatch 5 + , pkgsBuildBuild 6 , nixosTests 7 , fuse # only needed for grub-mount 8 , runtimeShell ··· 57 58 patches = [ 59 ./fix-bash-completion.patch 60 + (fetchpatch { 61 + name = "Add-hidden-menu-entries.patch"; 62 + # https://lists.gnu.org/archive/html/grub-devel/2016-04/msg00089.html 63 + url = "https://marc.info/?l=grub-devel&m=146193404929072&q=mbox"; 64 + sha256 = "00wa1q5adiass6i0x7p98vynj9vsz1w0gn1g4dgz89v35mpyw2bi"; 65 + }) 66 ]; 67 68 postPatch = if kbdcompSupport then ''