From b82c253b247152b0a722c403ff5a37bf68a455d1 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Mar 2012 17:14:52 +0000 Subject: [PATCH] Add a kernel patch for the efi boot stub to read a config file when booted without arguments, and base removable media booting off of that patch The patch is currently being discussed on LKML and hopefully will be included in mainline in some form in the future. Note that booting from the livecd has to do a lot of work before anything is output to the console, so if the drive is still busy don't assume the boot has hanged svn path=/nixos/trunk/; revision=33235 --- modules/installer/cd-dvd/iso-image.nix | 10 ++----- .../efi-boot-stub/efi-boot-stub-builder.sh | 6 ++-- .../installer/efi-boot-stub/efi-boot-stub.nix | 8 ++--- .../efi-boot-stub/nixos-boot-pkg.nix | 29 ------------------- 4 files changed, 7 insertions(+), 46 deletions(-) delete mode 100644 modules/installer/efi-boot-stub/nixos-boot-pkg.nix diff --git a/modules/installer/cd-dvd/iso-image.nix b/modules/installer/cd-dvd/iso-image.nix index 9e39eb48f3d..d775c855ad6 100644 --- a/modules/installer/cd-dvd/iso-image.nix +++ b/modules/installer/cd-dvd/iso-image.nix @@ -129,15 +129,11 @@ 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/nixos/bzImage + ${config.boot.kernelPackages.kernel + "/bzImage"} ::efi/boot/boot${targetArch}.efi ${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 + 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 ''; targetArch = if pkgs.stdenv.isi686 then diff --git a/modules/installer/efi-boot-stub/efi-boot-stub-builder.sh b/modules/installer/efi-boot-stub/efi-boot-stub-builder.sh index d736fb417a6..9df4cb1fe59 100644 --- a/modules/installer/efi-boot-stub/efi-boot-stub-builder.sh +++ b/modules/installer/efi-boot-stub/efi-boot-stub-builder.sh @@ -78,10 +78,8 @@ addEntry() { if test -n "@installRemovableMediaImage@"; then mkdir -pv "@efiSysMountPoint@"/efi/boot - cp "@removableMediaImage@" \ - "@efiSysMountPoint@"/efi/boot/boot"@targetArch@".efi - iconv -f utf-8 -t UCS-2 < $startup > "@efiSysMountPoint@"/efi/nixos/boot-params - filesCopied["@efiSysMountPoint@"/efi/nixos/boot-params]=1 + 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" diff --git a/modules/installer/efi-boot-stub/efi-boot-stub.nix b/modules/installer/efi-boot-stub/efi-boot-stub.nix index c8236b6fdd8..72b7fa28ac3 100644 --- a/modules/installer/efi-boot-stub/efi-boot-stub.nix +++ b/modules/installer/efi-boot-stub/efi-boot-stub.nix @@ -80,24 +80,20 @@ in ###### implementation let - efiBootStubBuilder = pkgs.substituteAll ({ + efiBootStubBuilder = pkgs.substituteAll { src = ./efi-boot-stub-builder.sh; 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; kernelFile = platform.kernelTarget; - } // pkgs.stdenv.lib.optionalAttrs config.boot.loader.efiBootStub.installRemovableMediaImage rec { - removableMediaImage = ''${import ./nixos-boot-pkg.nix { - inherit (pkgs) edk2 stdenv fetchhg; - }}/${targetArch}/NixosBoot.efi''; targetArch = if pkgs.stdenv.isi686 then "IA32" else if pkgs.stdenv.isx86_64 then "X64" else throw "Unsupported architecture"; - }); + }; # Temporary check, for nixos to cope both with nixpkgs stdenv-updates and trunk platform = pkgs.stdenv.platform; diff --git a/modules/installer/efi-boot-stub/nixos-boot-pkg.nix b/modules/installer/efi-boot-stub/nixos-boot-pkg.nix deleted file mode 100644 index 5bce1789a02..00000000000 --- a/modules/installer/efi-boot-stub/nixos-boot-pkg.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ stdenv, edk2, fetchhg }: - -let - - src = fetchhg { - url = https://bitbucket.org/shlevy/nixosbootpkg; - tag = "1ff4c2891c8c1eb03677a6f8b04b8d05807ec198"; - sha256 = "06zwy0g9a7g2sny7phvn2z76pb3wnw4vm9vsrjjaj7f7nzcsn13k"; - }; - -in - -stdenv.mkDerivation (edk2.setup "NixosBootPkg/NixosBootPkg.dsc" { - name = "NixosBootPkg-2012-03-15"; - - unpackPhase = '' - ln -sv ${src} NixosBootPkg - ln -sv ${edk2.src}/MdePkg . - ''; - - meta = { - description = - "Simple EFI app to load the kernel with NixOS-specific arguments"; - homepage = http://www.shealevy.com; - license = "MIT"; - maintainers = [ stdenv.lib.maintainers.shlevy ]; - platforms = ["x86_64-linux" "i686-linux"]; - }; -})