Subject: [bug#27705] [PATCH 3/4] gnu: grub-efi: Add grub.

From: Marius Bakke <[email-masked]>
Date: Mon, 17 Jul 2017 23:26:06 +0200

Danny Milosavljevic <[email-masked]> writes:

> * gnu/packages/bootloaders.scm (grub-efi)[native-inputs]: Add grub.
> [arguments]: Add phase "install-non-efi".

[...]

> +    (native-inputs
> +     `(("grub" ,grub)
> +       ,@(package-native-inputs grub)))

Since we take machine-specific code from it, I think it must be a
regular input.

However...

>      (arguments
>       `(;; TODO: Tests need a UEFI firmware for qemu. There is one at
>         ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
> @@ -180,7 +183,15 @@ menu to select one of the installed operating systems.")
>                         (("\"mcopy\"")
>                          (string-append "\"" mtools
>                                         "/bin/mcopy\"")))
> -                     #t))))))))))
> +                     #t)))
> +               (add-after 'install 'install-non-efi
> +                 (lambda* (#:key inputs outputs #:allow-other-keys)
> +                   ;; grub-mkresuce can use it for making a hybrid image.
> +                   (copy-recursively (string-append (assoc-ref inputs "grub")
> +                                                    "/lib/grub/i386-pc")
> +                                     (string-append (assoc-ref outputs "out")
> +                                                    "/lib/grub/i386-pc"))
> +                   #t)))))))))

I don't think we should do this in 'grub-efi'. Now users can not be
certain whether they have EFI boot or not, since grub will happily "fall
back" to i386-pc if it does not detect a UEFI system. It's a regression
of sorts.

However... The 'grub-hybrid' approach seems okay to me (although
building grub-efi again is unnecessary :)). If it works well, maybe we
could deprecate the other two GRUB packages.

FWIW Gentoo has taken the 'hybrid' approach for many years (building
once for each target platform and consolidating out/lib/grub). But it
would be good to know whether this configuration is supported upstream.