From 2f7d9c9f78ae36bc8eedd3969b131a393aded413 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Wed, 10 Jan 2018 21:14:52 -0500 Subject: [PATCH] Adds refind to the installer image. This is a 277K (as of right now) addition that can greatly help in some last recourse scenarios. The specific rEFInd setup will not be able to boot the installer image, but this is not why it has been added. It has been added to make use of its volumes scanning capabilities to boot existing EFI images on the target computer, which is sometimes necessary with buggy EFI. While is isn't NixOS's job to fix buggy EFI, shipping this small bit with the installer will help the unlucky few. Example scenario: two wildly different EFI implementation I have encountered have fatal flaws in which they sometimes will lose all the settings, this includes boot configuration. This is compounded by the fact that the two specific and distinct implementation do not allow manually adding ESP paths from their interface. The only recourse is to let the EFI boot the default paths, EFI/boot/boot{platform}.efi, which is not a default location used by the NixOS bootloaders. rEFInd is able to scan the volumes and detect the existing efi bootloaders, and boot them successfully. --- nixos/modules/installer/cd-dvd/iso-image.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index b6fa57242af7..0dbdd39d639a 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -98,6 +98,24 @@ let isolinuxCfg = concatStringsSep "\n" ([ baseIsolinuxCfg ] ++ optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry); + # Setup instructions for rEFInd. + refind = + if targetArch == "x64" then + '' + # Adds rEFInd to the ISO. + cp -v ${pkgs.refind}/share/refind/refind_x64.efi $out/EFI/boot/ + + # Makes it bootable through systemd-boot. + # It purposefully does not have a refind configuration file nor theme. + cat << EOF > $out/loader/entries/zz-rEFInd.conf + title rEFInd rescue bootloader + efi /EFI/boot/refind_x64.efi + EOF + '' + else + "# No refind for ia32" + ; + # The EFI boot image. efiDir = pkgs.runCommand "efi-directory" {} '' mkdir -p $out/EFI/boot @@ -141,6 +159,8 @@ let default nixos-iso timeout ${builtins.toString config.boot.loader.timeout} EOF + + ${refind} ''; efiImg = pkgs.runCommand "efi-image_eltorito" { buildInputs = [ pkgs.mtools pkgs.libfaketime ]; }