···162 isolinuxCfg = concatStringsSep "\n"
163 ([ baseIsolinuxCfg ] ++ optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry);
16400165 # 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}"
···186187 # 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
000190 # 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
···264265 cat <<EOF > $out/EFI/boot/grub.cfg
26600267 # 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
00000000276 ${grubMenuCfg}
277000000000000278 # 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 }
339340- 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- }
0000345 menuentry 'Firmware Setup' --class settings {
346 fwsetup
347 clear
···162 isolinuxCfg = concatStringsSep "\n"
163 ([ baseIsolinuxCfg ] ++ optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry);
164165+ 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}"
···188189 # 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
···269270 cat <<EOF > $out/EFI/boot/grub.cfg
271272+ 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}
292293+ 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 }
366367+ ${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