mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 21:33:03 +03:00
Enable building an efi-bootable ISO
svn path=/nixos/trunk/; revision=33140
This commit is contained in:
parent
b89a65e54c
commit
8efda48496
@ -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;
|
||||
|
@ -34,6 +34,9 @@ if test -n "$bootable"; then
|
||||
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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 =
|
||||
''
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user