From 7c01f4b8fb82924225541a50996eba26ad67ecfe Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Thu, 11 Feb 2021 20:26:26 -0800 Subject: [PATCH 1/2] grub2: fix cross-compilation * gettext is used for native binaries, not hosted libs * grub2 expects `BUILD_CC` to point to a native C compiler --- pkgs/tools/misc/grub/2.0x.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/misc/grub/2.0x.nix b/pkgs/tools/misc/grub/2.0x.nix index b97d086b972f..318fbba876cf 100644 --- a/pkgs/tools/misc/grub/2.0x.nix +++ b/pkgs/tools/misc/grub/2.0x.nix @@ -1,5 +1,6 @@ { lib, stdenv, fetchgit, flex, bison, python3, autoconf, automake, gnulib, libtool , gettext, ncurses, libusb-compat-0_1, freetype, qemu, lvm2, unifont, pkg-config +, pkgsBuildBuild , fuse # only needed for grub-mount , runtimeShell , zfs ? null @@ -62,11 +63,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 +102,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}"]; From 41c625ba8febecbc9bf9c4bb1a781759d758e14a Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Fri, 12 Feb 2021 00:57:57 -0800 Subject: [PATCH 2/2] grub2: add passthru.tests --- pkgs/tools/misc/grub/2.0x.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/tools/misc/grub/2.0x.nix b/pkgs/tools/misc/grub/2.0x.nix index 318fbba876cf..19d2e862ec4b 100644 --- a/pkgs/tools/misc/grub/2.0x.nix +++ b/pkgs/tools/misc/grub/2.0x.nix @@ -1,6 +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 @@ -125,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)";