Enable building an efi-bootable ISO

svn path=/nixos/trunk/; revision=33140
This commit is contained in:
Shea Levy
2012-03-16 05:37:24 +00:00
parent b89a65e54c
commit 8efda48496
5 changed files with 61 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -73,6 +73,14 @@ let
'';
};
isoImage.makeEfiBootable = mkOption {
default = false;
description = ''
Whether the ISO image should be an efi-bootable volume
'';
};
};
@@ -110,6 +118,20 @@ let
${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 @@ in
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 @@ in
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 =
''

View File

@@ -88,7 +88,7 @@ let
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