Switch to using efi shell + startup.nsh as the

removable media efi boot option.

svn path=/nixos/trunk/; revision=33984
This commit is contained in:
Shea Levy 2012-05-04 22:16:35 +00:00
parent 4b650026bf
commit 3aae8bfa61
3 changed files with 42 additions and 15 deletions

View File

@ -119,6 +119,17 @@ let
'';
efiShell = if pkgs.stdenv.isi686 then
pkgs.fetchurl {
url = "https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/Ia32/Shell_Full.efi";
sha256 = "0ymm3mbbwx9f6cq0bp2nr7ikyagxgsg4sjs5q1s4xbnms27slwjq";
}
else
pkgs.fetchurl {
url = "https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi";
sha256 = "1xchy8a05mgqzr82mmahdni0jbxsz6xf6vm2bg1bch9i6l72qgmh";
};
# The efi boot image
efiImg = pkgs.runCommand "efi-image_eltorito" {}
''
@ -129,11 +140,13 @@ let
${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/boot/boot${targetArch}.efi
${efiShell} ::efi/boot/boot${targetArch}.efi
${pkgs.mtools}/bin/mcopy -v -i "$out" \
${config.boot.kernelPackages.kernel + "/bzImage"} ::bzImage.efi
${pkgs.mtools}/bin/mcopy -v -i "$out" \
${config.system.build.initialRamdisk + "/initrd"} ::efi/nixos/initrd
echo "initrd=\\efi\\nixos\\initrd init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}" > boot-params
${pkgs.mtools}/bin/mcopy -v -i "$out" boot-params ::efi/boot/linux.conf
echo "bzImage.efi initrd=\\efi\\nixos\\initrd init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}" > boot-params
${pkgs.mtools}/bin/mcopy -v -i "$out" boot-params ::startup.nsh
'';
targetArch = if pkgs.stdenv.isi686 then

View File

@ -76,11 +76,6 @@ addEntry() {
set -e
fi
if test -n "@installRemovableMediaImage@"; then
mkdir -pv "@efiSysMountPoint@"/efi/boot
cp $kernel "@efiSysMountPoint@"/efi/boot/boot"@targetArch@".efi
sed 's|.*@kernelFile@.efi ||' $startup > "@efiSysMountPoint@"/efi/boot/linux.conf
fi
if test -n "@installStartupNsh@"; then
sed 's|.*@kernelFile@.efi|@kernelFile@.efi|' < $startup > "@efiSysMountPoint@/startup.nsh"
cp $kernel "@efiSysMountPoint@/@kernelFile@.efi"
@ -116,6 +111,11 @@ if test -n "@runEfibootmgr@"; then
set -e
fi
if test -n "@efiShell@"; then
mkdir -pv "@efiSysMountPoint@"/efi/boot
cp "@efiShell@" "@efiSysMountPoint@"/efi/boot/boot"@targetArch@".efi
fi
# Remove obsolete files from the EFI system partition
for fn in "@efiSysMountPoint@/efi/nixos/"*; do
if ! test "${filesCopied[$fn]}" = 1; then

View File

@ -59,15 +59,14 @@ let
'';
};
installRemovableMediaImage = mkOption {
installShell = mkOption {
default = false;
description = ''
Whether to build/install a BOOT{machine type short-name}.EFI file
in \EFI\BOOT. This _should_ only be needed for removable devices
Whether to install an EFI shell in \EFI\BOOT.
This _should_ only be needed for removable devices
(CDs, usb sticks, etc.), but it may be an option for broken
systems where efibootmgr doesn't work. It reads the UCS-2
encoded \EFI\NIXOS\BOOT-PARAMS to find out which kernel to boot
with which parameters.
systems where efibootmgr doesn't work. Particularly useful in
conjunction with installStartupNsh
'';
};
@ -85,7 +84,22 @@ let
isExecutable = true;
inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.glibc] ++ (pkgs.stdenv.lib.optionals config.boot.loader.efiBootStub.runEfibootmgr [pkgs.efibootmgr pkgs.module_init_tools]);
inherit (config.boot.loader.efiBootStub) efiSysMountPoint runEfibootmgr installStartupNsh efiDisk efiPartition installRemovableMediaImage;
inherit (config.boot.loader.efiBootStub) efiSysMountPoint runEfibootmgr installStartupNsh efiDisk efiPartition;
efiShell = if config.boot.loader.efiBootStub.installShell then
if pkgs.stdenv.isi686 then
pkgs.fetchurl {
url = "https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/Ia32/Shell_Full.efi";
sha256 = "0ymm3mbbwx9f6cq0bp2nr7ikyagxgsg4sjs5q1s4xbnms27slwjq";
}
else
pkgs.fetchurl {
url = "https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi";
sha256 = "1xchy8a05mgqzr82mmahdni0jbxsz6xf6vm2bg1bch9i6l72qgmh";
}
else
null;
kernelFile = platform.kernelTarget;
targetArch = if pkgs.stdenv.isi686 then
"IA32"