Author: shlevy
Date: Fri Mar 16 16:45:40 2012
New Revision: 33162
URL: https://nixos.org/websvn/nix/?rev=33162&sc=1

Log:
iso-image: Make efi-bootable cds actually bootable.

The image passed to genisofs needs to be a FAT image with the right filesystem
layout, not an EFI executable image

Modified:
   nixos/trunk/modules/installer/cd-dvd/iso-image.nix

Modified: nixos/trunk/modules/installer/cd-dvd/iso-image.nix
==============================================================================
--- nixos/trunk/modules/installer/cd-dvd/iso-image.nix  Fri Mar 16 15:32:03 
2012        (r33161)
+++ nixos/trunk/modules/installer/cd-dvd/iso-image.nix  Fri Mar 16 16:45:40 
2012        (r33162)
@@ -119,10 +119,25 @@
     '';
 
 
-  # The boot params for the efi boot stub
-  bootParams = pkgs.runCommand "boot-params_eltorito" {}
+  # The efi boot image
+  efiImg = pkgs.runCommand "efi-image_eltorito" {}
     ''
-      echo "\\boot\\bzImage initrd=\\boot\\initrd 
init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}" 
| iconv -f utf-8 -t UCS-2 > $out
+      #Let's hope 8M is enough
+      dd bs=2048 count=4096 if=/dev/zero of="$out"
+      ${pkgs.dosfstools}/sbin/mkfs.vfat "$out"
+      ${pkgs.mtools}/bin/mmd -i "$out" efi
+      ${pkgs.mtools}/bin/mmd -i "$out" efi/boot
+      ${pkgs.mtools}/bin/mmd -i "$out" efi/nixos
+      ${pkgs.mtools}/bin/mcopy -v -i "$out" \
+        ${config.boot.kernelPackages.kernel + "/bzImage"} ::efi/nixos/bzImage
+      ${pkgs.mtools}/bin/mcopy -v -i "$out" \
+        ${config.system.build.initialRamdisk + "/initrd"} ::efi/nixos/initrd
+      echo "\\efi\\nixos\\bzImage initrd=\\efi\\nixos\\initrd 
init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}" 
| iconv -f utf-8 -t UCS-2 > boot-params
+      ${pkgs.mtools}/bin/mcopy -v -i "$out" boot-params ::efi/nixos/boot-params
+      ${pkgs.mtools}/bin/mcopy -v -i "$out" \
+        ${import ../efi-boot-stub/nixos-boot-pkg.nix {
+          inherit (pkgs) edk2 stdenv fetchhg; 
+         }}/*/NixosBoot.efi ::efi/boot/boot${targetArch}.efi
     '';
 
   targetArch = if pkgs.stdenv.isi686 then
@@ -243,13 +258,8 @@
         target = "/nix/store";
       }
     ] ++ pkgs.stdenv.lib.optionals config.isoImage.makeEfiBootable [
-      { source = bootParams;
-        target = "/efi/nixos/boot-params";
-      }
-      { source = ''${import ../efi-boot-stub/nixos-boot-pkg.nix {
-                     inherit (pkgs) edk2 stdenv fetchhg; 
-                   }}/*/NixosBoot.efi'';
-        target = "/efi/boot/boot${targetArch}.efi";
+      { source = efiImg;
+        target = "/boot/efi.img";
       }
     ];
 
@@ -279,7 +289,7 @@
     bootImage = "/boot/grub/grub_eltorito";
   } // pkgs.stdenv.lib.optionalAttrs config.isoImage.makeEfiBootable {
     efiBootable = true;
-    efiBootImage = "efi/boot/boot${targetArch}.efi";
+    efiBootImage = "boot/efi.img";
   });
 
   boot.postBootCommands =
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to