Merge pull request #112857 from r-burns/grub-cross

grub2: fix cross-compilation
This commit is contained in:
Guillaume Girol 2021-02-18 11:57:46 +00:00 committed by GitHub
commit 5d7cecc090
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
, pkgsBuildBuild
, nixosTests
, fuse # only needed for grub-mount
, runtimeShell
, zfs ? null
@ -62,11 +64,13 @@ 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 ];
buildInputs = [ ncurses libusb-compat-0_1 freetype gettext lvm2 fuse libtool ]
nativeBuildInputs = [ bison flex python3 pkg-config autoconf automake gettext ];
buildInputs = [ ncurses libusb-compat-0_1 freetype lvm2 fuse libtool ]
++ optional doCheck qemu
++ optional zfsSupport zfs;
strictDeps = true;
hardeningDisable = [ "all" ];
# Work around a bug in the generated flex lexer (upstream flex bug?)
@ -99,7 +103,10 @@ stdenv.mkDerivation rec {
substituteInPlace ./configure --replace '/usr/share/fonts/unifont' '${unifont}/share/fonts'
'';
configureFlags = [ "--enable-grub-mount" ] # dep of os-prober
configureFlags = [
"--enable-grub-mount" # dep of os-prober
"BUILD_CC=${pkgsBuildBuild.stdenv.cc}/bin/cc"
]
++ 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}"];
@ -119,6 +126,14 @@ stdenv.mkDerivation rec {
sed -i $out/lib/grub/*/modinfo.sh -e "/grub_target_cppflags=/ s|'.*'|' '|"
'';
passthru.tests = {
nixos-grub = nixosTests.grub;
nixos-install-simple = nixosTests.installer.simple;
nixos-install-grub1 = nixosTests.installer.grub1;
nixos-install-grub-uefi = nixosTests.installer.simpleUefiGrub;
nixos-install-grub-uefi-spec = nixosTests.installer.simpleUefiGrubSpecialisation;
};
meta = with lib; {
description = "GNU GRUB, the Grand Unified Boot Loader (2.x beta)";