Author: shlevy
Date: Fri Mar 16 05:37:24 2012
New Revision: 33140
URL: https://nixos.org/websvn/nix/?rev=33140&sc=1

Log:
Enable building an efi-bootable ISO

Modified:
   nixos/trunk/lib/make-iso9660-image.nix
   nixos/trunk/lib/make-iso9660-image.sh
   nixos/trunk/modules/installer/cd-dvd/installation-cd-new-kernel.nix
   nixos/trunk/modules/installer/cd-dvd/iso-image.nix
   nixos/trunk/modules/installer/efi-boot-stub/efi-boot-stub.nix

Modified: nixos/trunk/lib/make-iso9660-image.nix
==============================================================================
--- nixos/trunk/lib/make-iso9660-image.nix      Fri Mar 16 03:20:12 2012        
(r33139)
+++ nixos/trunk/lib/make-iso9660-image.nix      Fri Mar 16 05:37:24 2012        
(r33140)
@@ -19,9 +19,15 @@
 , # Whether this should be an El-Torito bootable CD.
   bootable ? false
 
+, # Whether this should be an efi-bootable El-Torito CD.
+  efiBootable ? false
+
 , # The path (in the ISO file system) of the boot image.
   bootImage ? ""
 
+, # The path (in the ISO file system) of the efi boot image.
+  efiBootImage ? ""
+
 , # Whether to compress the resulting ISO image with bzip2.
   compressImage ? false
 
@@ -31,13 +37,14 @@
 }:
 
 assert bootable -> bootImage != "";
+assert efiBootable -> efiBootImage != "";
 
 stdenv.mkDerivation {
   name = "iso9660-image";
   builder = ./make-iso9660-image.sh;
   buildInputs = [perl cdrkit];
 
-  inherit isoName bootable bootImage compressImage volumeID pathsFromGraph;
+  inherit isoName bootable bootImage compressImage volumeID pathsFromGraph 
efiBootImage efiBootable;
 
   # !!! should use XML.
   sources = map (x: x.source) contents;

Modified: nixos/trunk/lib/make-iso9660-image.sh
==============================================================================
--- nixos/trunk/lib/make-iso9660-image.sh       Fri Mar 16 03:20:12 2012        
(r33139)
+++ nixos/trunk/lib/make-iso9660-image.sh       Fri Mar 16 05:37:24 2012        
(r33140)
@@ -34,6 +34,9 @@
     bootFlags="-b $bootImage -c .boot.cat -no-emul-boot -boot-load-size 4 
-boot-info-table"
 fi
 
+if test -n "$efiBootable"; then
+    bootFlags="$bootFlags -eltorito-alt-boot -e $efiBootImage -no-emul-boot"
+fi
 
 touch pathlist
 

Modified: nixos/trunk/modules/installer/cd-dvd/installation-cd-new-kernel.nix
==============================================================================
--- nixos/trunk/modules/installer/cd-dvd/installation-cd-new-kernel.nix Fri Mar 
16 03:20:12 2012        (r33139)
+++ nixos/trunk/modules/installer/cd-dvd/installation-cd-new-kernel.nix Fri Mar 
16 05:37:24 2012        (r33140)
@@ -3,6 +3,20 @@
 {
   require = [ ./installation-cd-graphical.nix ];
 
-  boot.kernelPackages = pkgs.linuxPackages_3_2;
+  boot.kernelPackages = pkgs.linuxPackages_3_3;
   boot.vesa = false;
+
+  # What follows should probably move into base once the base kernel has the
+  # efi boot stub
+
+  # Get a console as soon as the initrd loads fbcon on EFI boot
+  boot.initrd.kernelModules = [ "fbcon" ];
+
+  # Enable reading EFI variables via sysfs
+  boot.kernelModules = [ "efivars" ];
+
+  # efi-related tools
+  environment.systemPackages = [ pkgs.efibootmgr ];
+
+  isoImage.makeEfiBootable = true;
 }

Modified: nixos/trunk/modules/installer/cd-dvd/iso-image.nix
==============================================================================
--- nixos/trunk/modules/installer/cd-dvd/iso-image.nix  Fri Mar 16 03:20:12 
2012        (r33139)
+++ nixos/trunk/modules/installer/cd-dvd/iso-image.nix  Fri Mar 16 05:37:24 
2012        (r33140)
@@ -73,6 +73,14 @@
       '';
     };
 
+    isoImage.makeEfiBootable = mkOption {
+      default = false;
+      description = ''
+        Whether the ISO image should be an efi-bootable volume
+      '';
+    };
+
+
   };
 
 
@@ -110,6 +118,20 @@
       ${config.boot.loader.grub.extraEntries}
     '';
 
+
+  # The boot params for the efi boot stub
+  bootParams = pkgs.runCommand "boot-params_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
+    '';
+
+  targetArch = if pkgs.stdenv.isi686 then
+    "IA32"
+  else if pkgs.stdenv.isx86_64 then
+    "x64"
+  else
+    throw "Unsupported architecture";
+
 in
 
 {
@@ -220,6 +242,13 @@
         source = pkgs.runCommand "empty" {} "ensureDir $out";
         target = "/nix/store";
       }
+    ] ++ pkgs.stdenv.lib.optionals config.isoImage.makeEfiBootable [
+      { source = bootParams;
+        target = "/efi/nixos/boot-params";
+      }
+      { source = "${pkgs.NixosBootPkg}/*/NixosBoot.efi";
+        target = "/efi/boot/boot${targetArch}.efi";
+      }
     ];
 
   # The Grub menu.
@@ -239,14 +268,17 @@
   boot.loader.grub.timeout = 10;
 
   # Create the ISO image.
-  system.build.isoImage = import ../../../lib/make-iso9660-image.nix {
+  system.build.isoImage = import ../../../lib/make-iso9660-image.nix ({
     inherit (pkgs) stdenv perl cdrkit pathsFromGraph;
 
     inherit (config.isoImage) isoName compressImage volumeID contents;
 
     bootable = true;
     bootImage = "/boot/grub/grub_eltorito";
-  };
+  } // pkgs.stdenv.lib.optionalAttrs config.isoImage.makeEfiBootable {
+    efiBootable = true;
+    efiBootImage = "efi/boot/boot${targetArch}.efi";
+  });
 
   boot.postBootCommands =
     ''

Modified: nixos/trunk/modules/installer/efi-boot-stub/efi-boot-stub.nix
==============================================================================
--- nixos/trunk/modules/installer/efi-boot-stub/efi-boot-stub.nix       Fri Mar 
16 03:20:12 2012        (r33139)
+++ nixos/trunk/modules/installer/efi-boot-stub/efi-boot-stub.nix       Fri Mar 
16 05:37:24 2012        (r33140)
@@ -88,7 +88,7 @@
     inherit (config.boot.loader.efiBootStub) efiSysMountPoint runEfibootmgr 
installStartupNsh efiDisk efiPartition installRemovableMediaImage;
     kernelFile = platform.kernelTarget;
   } // pkgs.stdenv.lib.optionalAttrs 
config.boot.loader.efiBootStub.installRemovableMediaImage {
-    removableMediaImage = "${pkgs.NixosBootPkg}/X64/NixosBoot.efi";
+    removableMediaImage = "${pkgs.NixosBootPkg}/*/NixosBoot.efi";
     targetArch = if pkgs.stdenv.isi686 then
       "IA32"
     else if pkgs.stdenv.isx86_64 then
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to