summary refs log tree commit diff
path: root/nixos/modules/installer
diff options
context:
space:
mode:
authorSamuel Dionne-Riel <samuel@dionne-riel.com>2018-01-10 21:14:52 -0500
committerSamuel Dionne-Riel <samuel@dionne-riel.com>2018-08-24 13:04:56 -0400
commit2f7d9c9f78ae36bc8eedd3969b131a393aded413 (patch)
tree09784d1e8f44e76314ba6ec6b7e213e8d85aea2c /nixos/modules/installer
parent853475fed771dcde688cc6cc63e66bddfc37489c (diff)
downloadnixlib-2f7d9c9f78ae36bc8eedd3969b131a393aded413.tar
nixlib-2f7d9c9f78ae36bc8eedd3969b131a393aded413.tar.gz
nixlib-2f7d9c9f78ae36bc8eedd3969b131a393aded413.tar.bz2
nixlib-2f7d9c9f78ae36bc8eedd3969b131a393aded413.tar.lz
nixlib-2f7d9c9f78ae36bc8eedd3969b131a393aded413.tar.xz
nixlib-2f7d9c9f78ae36bc8eedd3969b131a393aded413.tar.zst
nixlib-2f7d9c9f78ae36bc8eedd3969b131a393aded413.zip
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.
Diffstat (limited to 'nixos/modules/installer')
-rw-r--r--nixos/modules/installer/cd-dvd/iso-image.nix20
1 files changed, 20 insertions, 0 deletions
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 ]; }