about summary refs log tree commit diff
path: root/nixos/modules/system/boot/loader/grub/grub.nix
diff options
context:
space:
mode:
authorFlorian Franzen <Florian.Franzen@gmail.com>2019-01-28 12:00:58 +0100
committerFlorian Franzen <Florian.Franzen@gmail.com>2019-03-18 10:38:07 +0100
commite51a8402597b7d3ba505b35451c86c8c7bf63d5e (patch)
treebdae0783032c599a1ca0ac7c5e471f1a65dc5854 /nixos/modules/system/boot/loader/grub/grub.nix
parentca5004e26cb312bb8576a14788d073ee5db768b4 (diff)
downloadnixlib-e51a8402597b7d3ba505b35451c86c8c7bf63d5e.tar
nixlib-e51a8402597b7d3ba505b35451c86c8c7bf63d5e.tar.gz
nixlib-e51a8402597b7d3ba505b35451c86c8c7bf63d5e.tar.bz2
nixlib-e51a8402597b7d3ba505b35451c86c8c7bf63d5e.tar.lz
nixlib-e51a8402597b7d3ba505b35451c86c8c7bf63d5e.tar.xz
nixlib-e51a8402597b7d3ba505b35451c86c8c7bf63d5e.tar.zst
nixlib-e51a8402597b7d3ba505b35451c86c8c7bf63d5e.zip
grub: Support 32bit EFI on 64bit x86 platforms
Diffstat (limited to 'nixos/modules/system/boot/loader/grub/grub.nix')
-rw-r--r--nixos/modules/system/boot/loader/grub/grub.nix35
1 files changed, 22 insertions, 13 deletions
diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix
index a1537ad3cedc..d3cf8b29bb46 100644
--- a/nixos/modules/system/boot/loader/grub/grub.nix
+++ b/nixos/modules/system/boot/loader/grub/grub.nix
@@ -8,13 +8,17 @@ let
 
   efi = config.boot.loader.efi;
 
-  realGrub = if cfg.version == 1 then pkgs.grub
-    else if cfg.zfsSupport then pkgs.grub2.override { zfsSupport = true; }
+  grubPkgs = 
+    # Package set of targeted architecture
+    if cfg.forcei686 then pkgs.pkgsi686Linux else pkgs;
+
+  realGrub = if cfg.version == 1 then grubPkgs.grub
+    else if cfg.zfsSupport then grubPkgs.grub2.override { zfsSupport = true; }
     else if cfg.trustedBoot.enable
          then if cfg.trustedBoot.isHPLaptop
-              then pkgs.trustedGrub-for-HP
-              else pkgs.trustedGrub
-         else pkgs.grub2;
+              then grubPkgs.trustedGrub-for-HP
+              else grubPkgs.trustedGrub
+         else grubPkgs.grub2;
 
   grub =
     # Don't include GRUB if we're only generating a GRUB menu (e.g.,
@@ -58,14 +62,10 @@ let
         version extraConfig extraPerEntryConfig extraEntries forceInstall useOSProber
         extraEntriesBeforeNixOS extraPrepareConfig extraInitrd configurationLimit copyKernels
         default fsIdentifier efiSupport efiInstallAsRemovable gfxmodeEfi gfxmodeBios;
-      path = (makeBinPath ([
-        pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils pkgs.btrfs-progs
-        pkgs.utillinux ]
-        ++ (optional (cfg.efiSupport && (cfg.version == 2)) pkgs.efibootmgr)
-        ++ (optionals cfg.useOSProber [pkgs.busybox pkgs.os-prober])
-      )) + ":" + (makeSearchPathOutput "bin" "sbin" [
-        pkgs.mdadm pkgs.utillinux
-      ]);
+      path = with pkgs; makeBinPath (
+        [ coreutils gnused gnugrep findutils diffutils btrfs-progs utillinux mdadm ]
+        ++ optional (cfg.efiSupport && (cfg.version == 2)) efibootmgr
+        ++ optionals cfg.useOSProber [ busybox os-prober ]);
       font = if cfg.font == null then ""
         else (if lib.last (lib.splitString "." cfg.font) == "pf2"
              then cfg.font
@@ -512,6 +512,15 @@ in
         '';
       };
 
+      forcei686 = mkOption {
+        default = false;
+        type = types.bool;
+        description = ''
+          Whether to force the use of a ia32 boot loader on x64 systems. Required 
+          to install and run NixOS on 64bit x86 systems with 32bit (U)EFI.
+        '';
+      };
+
       trustedBoot = {
 
         enable = mkOption {