From c891134b77c05b98d1fc89f2bac394dbe4382fe8 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Wed, 10 Jun 2015 11:50:21 -0700 Subject: [PATCH] nixos/grub: Prevent module errors and make gfxmode configurable --- .../modules/system/boot/loader/grub/grub.nix | 22 +++++++++++++++++-- .../system/boot/loader/grub/install-grub.pl | 20 ++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix index 0b6333ab573b..cb01774f9ab6 100644 --- a/nixos/modules/system/boot/loader/grub/grub.nix +++ b/nixos/modules/system/boot/loader/grub/grub.nix @@ -28,7 +28,7 @@ let f = x: if x == null then "" else "" + x; grubConfig = args: pkgs.writeText "grub-config.xml" (builtins.toXML - { splashImage = f config.boot.loader.grub.splashImage; + { splashImage = f cfg.splashImage; grub = f grub; grubTarget = f (grub.grubTarget or ""); shell = "${pkgs.stdenv.shell}"; @@ -42,7 +42,7 @@ let inherit (cfg) version extraConfig extraPerEntryConfig extraEntries extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels timeout - default fsIdentifier efiSupport; + default fsIdentifier efiSupport gfxmodeEfi gfxmodeBios; path = (makeSearchPath "bin" ([ pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils pkgs.btrfsProgs pkgs.utillinux ] ++ (if cfg.efiSupport && (cfg.version == 2) then [pkgs.efibootmgr ] else []) @@ -242,6 +242,24 @@ in ''; }; + gfxmodeEfi = mkOption { + default = "auto"; + example = "1024x768"; + type = types.str; + description = '' + The gfxmode to pass to grub when loading a graphical boot interface under efi. + ''; + }; + + gfxmodeBios = mkOption { + default = "1024x768"; + example = "auto"; + type = types.str; + description = '' + The gfxmode to pass to grub when loading a graphical boot interface under bios. + ''; + }; + configurationLimit = mkOption { default = 100; example = 120; diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index fcf5871203d5..016b5a23ed4b 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -57,6 +57,8 @@ my $grubTargetEfi = get("grubTargetEfi"); my $bootPath = get("bootPath"); my $canTouchEfiVariables = get("canTouchEfiVariables"); my $efiSysMountPoint = get("efiSysMountPoint"); +my $gfxmodeEfi = get("gfxmodeEfi"); +my $gfxmodeBios = get("gfxmodeBios"); $ENV{'PATH'} = get("path"); die "unsupported GRUB version\n" if $grubVersion != 1 && $grubVersion != 2; @@ -255,14 +257,22 @@ else { fi # Setup the graphics stack for bios and efi systems - insmod vbe - insmod efi_gop - insmod efi_uga + if [ \"\${grub_platform}\" = \"efi\" ]; then + insmod efi_gop + insmod efi_uga + else + insmod vbe + fi insmod font if loadfont " . $grubBoot->path . "/grub/fonts/unicode.pf2; then insmod gfxterm - set gfxmode=auto - set gfxpayload=keep + if [ \"\${grub_platform}\" = \"efi\" ]; then + set gfxmode=$gfxmodeEfi + set gfxpayload=keep + else + set gfxmode=$gfxmodeBios + set gfxpayload=text + fi terminal_output gfxterm fi ";