summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2015-06-10 11:50:21 -0700
committerWilliam A. Kennington III <william@wkennington.com>2015-06-10 11:50:35 -0700
commitc891134b77c05b98d1fc89f2bac394dbe4382fe8 (patch)
tree5534510a626a7d007f7fa54b64e73d06c30e0851 /nixos
parentaece1407d5a568e90d0c680fbc58266759cf6db4 (diff)
downloadnixlib-c891134b77c05b98d1fc89f2bac394dbe4382fe8.tar
nixlib-c891134b77c05b98d1fc89f2bac394dbe4382fe8.tar.gz
nixlib-c891134b77c05b98d1fc89f2bac394dbe4382fe8.tar.bz2
nixlib-c891134b77c05b98d1fc89f2bac394dbe4382fe8.tar.lz
nixlib-c891134b77c05b98d1fc89f2bac394dbe4382fe8.tar.xz
nixlib-c891134b77c05b98d1fc89f2bac394dbe4382fe8.tar.zst
nixlib-c891134b77c05b98d1fc89f2bac394dbe4382fe8.zip
nixos/grub: Prevent module errors and make gfxmode configurable
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/system/boot/loader/grub/grub.nix22
-rw-r--r--nixos/modules/system/boot/loader/grub/install-grub.pl20
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
     ";