pvgrub_image: add package

Add a package containing a pvgrub image for xen generated from grub2

+63 -1
+4 -1
pkgs/tools/misc/grub/2.0x.nix
··· 3 3 , zfs ? null 4 4 , efiSupport ? false 5 5 , zfsSupport ? true 6 + , xenSupport ? false 6 7 }: 7 8 8 9 with stdenv.lib; ··· 46 47 47 48 assert efiSupport -> canEfi; 48 49 assert zfsSupport -> zfs != null; 50 + assert !(efiSupport && xenSupport); 49 51 50 52 stdenv.mkDerivation rec { 51 53 name = "grub-${version}"; ··· 98 100 patches = [ ./fix-bash-completion.patch ]; 99 101 100 102 configureFlags = optional zfsSupport "--enable-libzfs" 101 - ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.system}.target}" "--program-prefix=" ]; 103 + ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.system}.target}" "--program-prefix=" ] 104 + ++ optionals xenSupport [ "--with-platform=xen" "--target=${efiSystemsBuild.${stdenv.system}.target}"]; 102 105 103 106 # save target that grub is compiled for 104 107 grubTarget = if efiSupport
+1
pkgs/tools/misc/grub/pvgrub_image/configs/grub-bootstrap.cfg
··· 1 + normal (memdisk)/grub.cfg
+10
pkgs/tools/misc/grub/pvgrub_image/configs/grub.cfg
··· 1 + # The parentheses around ${root} here to match Grub's config file syntax 2 + if search -s -f /boot/grub/grub.cfg ; then 3 + echo "Reading (${root})/boot/grub/grub.cfg" 4 + configfile /boot/grub/grub.cfg 5 + fi 6 + 7 + if search -s -f /grub/grub.cfg ; then 8 + echo "Reading (${root})/grub/grub.cfg" 9 + configfile /grub/grub.cfg 10 + fi
+42
pkgs/tools/misc/grub/pvgrub_image/default.nix
··· 1 + { stdenv, grub2_xen }: 2 + 3 + with stdenv.lib; 4 + let 5 + efiSystemsBuild = { 6 + "i686-linux".target = "i386"; 7 + "x86_64-linux".target = "x86_64"; 8 + "aarch64-linux".target = "aarch64"; 9 + }; 10 + 11 + in ( 12 + 13 + stdenv.mkDerivation rec { 14 + name = "pvgrub-image"; 15 + 16 + configs = ./configs; 17 + 18 + buildInputs = [ grub2_xen ]; 19 + 20 + buildCommand = '' 21 + cp "${configs}"/* . 22 + tar -cf memdisk.tar grub.cfg 23 + # We include all modules except all_video.mod as otherwise grub will fail printing "no symbol table" 24 + # if we include it. 25 + grub-mkimage -O "${efiSystemsBuild.${stdenv.system}.target}-xen" -c grub-bootstrap.cfg \ 26 + -m memdisk.tar -o "grub-${efiSystemsBuild.${stdenv.system}.target}-xen.bin" \ 27 + $(ls "${grub2_xen}/lib/grub/${efiSystemsBuild.${stdenv.system}.target}-xen/" |grep 'mod''$'|grep -v '^all_video\.mod''$') 28 + mkdir -p "$out/lib/grub-xen" 29 + cp "grub-${efiSystemsBuild.${stdenv.system}.target}-xen.bin" $out/lib/grub-xen/ 30 + ''; 31 + 32 + meta = with stdenv.lib; { 33 + description = "PvGrub image for use for booting PV Xen guests"; 34 + 35 + longDescription = 36 + '' This package provides a PvGrub image for booting Para-Virtualized (PV) 37 + Xen guests 38 + ''; 39 + 40 + platforms = platforms.gnu; 41 + }; 42 + })
+6
pkgs/top-level/all-packages.nix
··· 2258 2258 zfsSupport = false; 2259 2259 }; 2260 2260 2261 + grub2_xen = callPackage ../tools/misc/grub/2.0x.nix { 2262 + xenSupport = true; 2263 + }; 2264 + 2265 + grub2_pvgrub_image = callPackage ../tools/misc/grub/pvgrub_image { }; 2266 + 2261 2267 grub4dos = callPackage ../tools/misc/grub4dos { 2262 2268 stdenv = stdenv_32bit; 2263 2269 };