about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/misc/grub/2.0x.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/misc/grub/2.0x.nix')
-rw-r--r--nixpkgs/pkgs/tools/misc/grub/2.0x.nix28
1 files changed, 24 insertions, 4 deletions
diff --git a/nixpkgs/pkgs/tools/misc/grub/2.0x.nix b/nixpkgs/pkgs/tools/misc/grub/2.0x.nix
index 29ce5b23faaa..fcf29beb1882 100644
--- a/nixpkgs/pkgs/tools/misc/grub/2.0x.nix
+++ b/nixpkgs/pkgs/tools/misc/grub/2.0x.nix
@@ -1,5 +1,7 @@
 { lib, stdenv, fetchgit, flex, bison, python3, autoconf, automake, gnulib, libtool
 , gettext, ncurses, libusb-compat-0_1, freetype, qemu, lvm2, unifont, pkg-config
+, buildPackages
+, fetchpatch
 , pkgsBuildBuild
 , nixosTests
 , fuse # only needed for grub-mount
@@ -21,6 +23,7 @@ let
   efiSystemsBuild = {
     i686-linux.target = "i386";
     x86_64-linux.target = "x86_64";
+    armv7l-linux.target = "arm";
     aarch64-linux.target = "aarch64";
   };
 
@@ -29,6 +32,7 @@ let
   efiSystemsInstall = {
     i686-linux.target = "i386";
     x86_64-linux.target = "x86_64";
+    armv7l-linux.target = "arm";
     aarch64-linux.target = "arm64";
   };
 
@@ -55,6 +59,12 @@ stdenv.mkDerivation rec {
 
   patches = [
     ./fix-bash-completion.patch
+    (fetchpatch {
+      name = "Add-hidden-menu-entries.patch";
+      # https://lists.gnu.org/archive/html/grub-devel/2016-04/msg00089.html
+      url = "https://marc.info/?l=grub-devel&m=146193404929072&q=mbox";
+      sha256 = "00wa1q5adiass6i0x7p98vynj9vsz1w0gn1g4dgz89v35mpyw2bi";
+    })
   ];
 
   postPatch = if kbdcompSupport then ''
@@ -64,7 +74,8 @@ stdenv.mkDerivation rec {
     echo 'echo "Compile grub2 with { kbdcompSupport = true; } to enable support for this command."' >> util/grub-kbdcomp.in
   '';
 
-  nativeBuildInputs = [ bison flex python3 pkg-config autoconf automake gettext ];
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [ bison flex python3 pkg-config autoconf automake gettext freetype ];
   buildInputs = [ ncurses libusb-compat-0_1 freetype lvm2 fuse libtool ]
     ++ optional doCheck qemu
     ++ optional zfsSupport zfs;
@@ -105,9 +116,18 @@ stdenv.mkDerivation rec {
 
   configureFlags = [
     "--enable-grub-mount" # dep of os-prober
-    "BUILD_CC=${pkgsBuildBuild.stdenv.cc}/bin/cc"
-  ]
-    ++ optional zfsSupport "--enable-libzfs"
+  ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    # grub doesn't do cross-compilation as usual and tries to use unprefixed
+    # tools to target the host. Provide toolchain information explicitly for
+    # cross builds.
+    #
+    # Ref: # https://github.com/buildroot/buildroot/blob/master/boot/grub2/grub2.mk#L108
+    "TARGET_CC=${stdenv.cc.targetPrefix}cc"
+    "TARGET_NM=${stdenv.cc.targetPrefix}nm"
+    "TARGET_OBJCOPY=${stdenv.cc.targetPrefix}objcopy"
+    "TARGET_RANLIB=${stdenv.cc.targetPrefix}ranlib"
+    "TARGET_STRIP=${stdenv.cc.targetPrefix}strip"
+  ] ++ optional zfsSupport "--enable-libzfs"
     ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}" "--program-prefix=" ]
     ++ optionals xenSupport [ "--with-platform=xen" "--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}"];