File tree 2 files changed +34
-2
lines changed
nixos/modules/system/boot/loader/grub
2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 64
64
) ) + ":" + ( makeSearchPathOutput "bin" "sbin" [
65
65
pkgs . mdadm pkgs . utillinux
66
66
] ) ;
67
+ font = if lib . last ( lib . splitString "." cfg . font ) == "pf2"
68
+ then cfg . font
69
+ else "${ convertedFont } " ;
67
70
} ) ;
68
71
69
72
bootDeviceCounters = fold ( device : attr : attr // { "${ device } " = ( attr . "${ device } " or 0 ) + 1 ; } ) { }
70
73
( concatMap ( args : args . devices ) cfg . mirroredBoots ) ;
71
74
75
+ convertedFont = ( pkgs . runCommand "grub-font-converted.pf2" { }
76
+ ( builtins . concatStringsSep " "
77
+ ( [ "${ realGrub } /bin/grub-mkfont"
78
+ cfg . font
79
+ "--output" "$out"
80
+ ] ++ ( optional ( cfg . fontSize != null ) "--size ${ toString cfg . fontSize } " ) ) )
81
+ ) ;
72
82
in
73
83
74
84
{
276
286
extraInitrd = mkOption {
277
287
type = types . nullOr types . path ;
278
288
default = null ;
279
- example = "/boot/extra_initrafms .gz" ;
289
+ example = "/boot/extra_initramfs .gz" ;
280
290
description = ''
281
291
The path to a second initramfs to be supplied to the kernel.
282
292
This ramfs will not be copied to the store, so that it can
305
315
'' ;
306
316
} ;
307
317
318
+ font = mkOption {
319
+ type = types . nullOr types . path ;
320
+ default = "${ realGrub } /share/grub/unicode.pf2" ;
321
+ description = ''
322
+ Path to a TrueType, OpenType, or pf2 font to be used by Grub.
323
+ '' ;
324
+ } ;
325
+
326
+ fontSize = mkOption {
327
+ type = types . nullOr types . int ;
328
+ example = literalExample 16 ;
329
+ default = null ;
330
+ description = ''
331
+ Font size for the grub menu. Ignored unless <literal>font</literal>
332
+ is set to a ttf or otf font.
333
+ '' ;
334
+ } ;
335
+
308
336
gfxmodeEfi = mkOption {
309
337
default = "auto" ;
310
338
example = "1024x768" ;
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ sub runCommand {
67
67
my $gfxmodeBios = get(" gfxmodeBios" );
68
68
my $bootloaderId = get(" bootloaderId" );
69
69
my $forceInstall = get(" forceInstall" );
70
+ my $font = get(" font" );
70
71
$ENV {' PATH' } = get(" path" );
71
72
72
73
die " unsupported GRUB version\n " if $grubVersion != 1 && $grubVersion != 2;
@@ -281,7 +282,7 @@ sub GrubFs {
281
282
insmod vbe
282
283
fi
283
284
insmod font
284
- if loadfont " . $grubBoot -> path . " /grub/fonts/unicode .pf2; then
285
+ if loadfont " . $grubBoot -> path . " /converted-font .pf2; then
285
286
insmod gfxterm
286
287
if [ \"\$ {grub_platform}\" = \" efi\" ]; then
287
288
set gfxmode=$gfxmodeEfi
@@ -294,6 +295,9 @@ sub GrubFs {
294
295
fi
295
296
" ;
296
297
298
+ if ($font ) {
299
+ copy $font , " $bootPath /converted-font.pf2" or die " cannot copy $font to $bootPath \n " ;
300
+ }
297
301
if ($splashImage ) {
298
302
# FIXME: GRUB 1.97 doesn't resize the background image if it
299
303
# doesn't match the video resolution.
You can’t perform that action at this time.
0 commit comments