git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #54625 from FlorianFranzen/efi32

grub: Support 32bit EFI on 64bit platforms

commit73be6fba8b7c02e2b7dc22298d2bdbd8ece7bc80 authorMatthew Bauer <mjbauer95@gmail.com> dateThu 21 Mar 2019, 11:39 (8 years ago) parent6e982c4e51a840
2 files changed+29−18
nixos/modules/installer/cd-dvd/iso-image.nix+7−5 nixos/modules/system/boot/loader/grub/grub.nix+22−13
nixos/modules/installer/cd-dvd/iso-image.nix+7−5
@@ -165,6 +165,8 @@ let
165165 else
166166 "# No refind for ${targetArch}"
167167 ;
168+
169+ grubPkgs = if config.boot.loader.grub.forcei686 then pkgs.pkgsi686Linux else pkgs;
168170
169171 grubMenuCfg = ''
170172 #
@@ -241,7 +243,7 @@ let
241243 # Modules that may or may not be available per-platform.
242244 echo "Adding additional modules:"
243245 for mod in efi_uga; do
244− if [ -f ${pkgs.grub2_efi}/lib/grub/${pkgs.grub2_efi.grubTarget}/$mod.mod ]; then
246+ if [ -f ${grubPkgs.grub2_efi}/lib/grub/${grubPkgs.grub2_efi.grubTarget}/$mod.mod ]; then
245247 echo " - $mod"
246248 MODULES+=" $mod"
247249 fi
@@ -249,9 +251,9 @@ let
249251
250252 # Make our own efi program, we can't rely on "grub-install" since it seems to
251253 # probe for devices, even with --skip-fs-probe.
252− ${pkgs.grub2_efi}/bin/grub-mkimage -o $out/EFI/boot/boot${targetArch}.efi -p /EFI/boot -O ${pkgs.grub2_efi.grubTarget} \
254+ ${grubPkgs.grub2_efi}/bin/grub-mkimage -o $out/EFI/boot/boot${targetArch}.efi -p /EFI/boot -O ${grubPkgs.grub2_efi.grubTarget} \
253255 $MODULES
254− cp ${pkgs.grub2_efi}/share/grub/unicode.pf2 $out/EFI/boot/
256+ cp ${grubPkgs.grub2_efi}/share/grub/unicode.pf2 $out/EFI/boot/
255257
256258 cat <<EOF > $out/EFI/boot/grub.cfg
257259
@@ -362,7 +364,7 @@ let
362364
363365 # Name used by UEFI for architectures.
364366 targetArch =
365− if pkgs.stdenv.isi686 then
367+ if pkgs.stdenv.isi686 || config.boot.loader.grub.forcei686 then
366368 "ia32"
367369 else if pkgs.stdenv.isx86_64 then
368370 "x64"
@@ -506,7 +508,7 @@ in
506508 # here and it causes a cyclic dependency.
507509 boot.loader.grub.enable = false;
508510
509− environment.systemPackages = [ pkgs.grub2 pkgs.grub2_efi ]
511+ environment.systemPackages = [ grubPkgs.grub2 grubPkgs.grub2_efi ]
510512 ++ optional canx86BiosBoot pkgs.syslinux
511513 ;
512514
nixos/modules/system/boot/loader/grub/grub.nix+22−13
@@ -8,13 +8,17 @@ let
88
99 efi = config.boot.loader.efi;
1010
11− realGrub = if cfg.version == 1 then pkgs.grub
12− else if cfg.zfsSupport then pkgs.grub2.override { zfsSupport = true; }
11+ grubPkgs =
12+ # Package set of targeted architecture
13+ if cfg.forcei686 then pkgs.pkgsi686Linux else pkgs;
14+
15+ realGrub = if cfg.version == 1 then grubPkgs.grub
16+ else if cfg.zfsSupport then grubPkgs.grub2.override { zfsSupport = true; }
1317 else if cfg.trustedBoot.enable
1418 then if cfg.trustedBoot.isHPLaptop
15− then pkgs.trustedGrub-for-HP
16− else pkgs.trustedGrub
17− else pkgs.grub2;
19+ then grubPkgs.trustedGrub-for-HP
20+ else grubPkgs.trustedGrub
21+ else grubPkgs.grub2;
1822
1923 grub =
2024 # Don't include GRUB if we're only generating a GRUB menu (e.g.,
@@ -58,14 +62,10 @@ let
5862 version extraConfig extraPerEntryConfig extraEntries forceInstall useOSProber
5963 extraEntriesBeforeNixOS extraPrepareConfig extraInitrd configurationLimit copyKernels
6064 default fsIdentifier efiSupport efiInstallAsRemovable gfxmodeEfi gfxmodeBios;
61− path = (makeBinPath ([
62− pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils pkgs.btrfs-progs
63− pkgs.utillinux ]
64− ++ (optional (cfg.efiSupport && (cfg.version == 2)) pkgs.efibootmgr)
65− ++ (optionals cfg.useOSProber [pkgs.busybox pkgs.os-prober])
66− )) + ":" + (makeSearchPathOutput "bin" "sbin" [
67− pkgs.mdadm pkgs.utillinux
68− ]);
65+ path = with pkgs; makeBinPath (
66+ [ coreutils gnused gnugrep findutils diffutils btrfs-progs utillinux mdadm ]
67+ ++ optional (cfg.efiSupport && (cfg.version == 2)) efibootmgr
68+ ++ optionals cfg.useOSProber [ busybox os-prober ]);
6969 font = if cfg.font == null then ""
7070 else (if lib.last (lib.splitString "." cfg.font) == "pf2"
7171 then cfg.font
@@ -512,6 +512,15 @@ in
512512 '';
513513 };
514514
515+ forcei686 = mkOption {
516+ default = false;
517+ type = types.bool;
518+ description = ''
519+ Whether to force the use of a ia32 boot loader on x64 systems. Required
520+ to install and run NixOS on 64bit x86 systems with 32bit (U)EFI.
521+ '';
522+ };
523+
515524 trustedBoot = {
516525
517526 enable = mkOption {