diff --git a/pkgs/by-name/gr/grub2-xen-images/package.nix b/pkgs/by-name/gr/grub2-xen-images/package.nix index 3aa240ed9feef..4aedd4d680c3f 100644 --- a/pkgs/by-name/gr/grub2-xen-images/package.nix +++ b/pkgs/by-name/gr/grub2-xen-images/package.nix @@ -1,54 +1,60 @@ -{ - lib, - stdenv, - grub2_xen, -}: +{ lib, stdenv, buildPvImage ? false, grub2_xen, buildPvhImage ? false +, grub2_xen_pvh, }: +assert (buildPvImage != buildPvhImage); let efiSystemsBuild = { i686-linux.target = "i386"; - x86_64-linux.target = "x86_64"; + x86_64-linux.target = if buildPvhImage then "i386" else "x86_64"; armv7l-linux.target = "arm"; aarch64-linux.target = "aarch64"; riscv32-linux.target = "riscv32"; riscv64-linux.target = "riscv64"; }; -in -( +in ( stdenv.mkDerivation rec { - name = "pvgrub-image"; + name = "grub2-xen-images"; configs = ./configs; - buildInputs = [ grub2_xen ]; + buildInputs = lib.optional buildPvImage grub2_xen + ++ lib.optional buildPvhImage grub2_xen_pvh; - buildCommand = '' + buildCommand = let grubVariant = if buildPvImage then "xen" else "xen_pvh"; + in '' cp "${configs}"/* . tar -cf memdisk.tar grub.cfg # We include all modules except all_video.mod as otherwise grub will fail printing "no symbol table" # if we include it. - grub-mkimage -O "${ - efiSystemsBuild.${stdenv.hostPlatform.system}.target - }-xen" -c grub-bootstrap.cfg \ - -m memdisk.tar -o "grub-${efiSystemsBuild.${stdenv.hostPlatform.system}.target}-xen.bin" \ - $(ls "${grub2_xen}/lib/grub/${ + grub-mkimage \ + -O "${ + efiSystemsBuild.${stdenv.hostPlatform.system}.target + }-${grubVariant}" \ + -c grub-bootstrap.cfg \ + -m memdisk.tar \ + -o "grub-${ efiSystemsBuild.${stdenv.hostPlatform.system}.target - }-xen/" |grep 'mod''$'|grep -v '^all_video\.mod''$') - mkdir -p "$out/lib/grub-xen" - cp "grub-${efiSystemsBuild.${stdenv.hostPlatform.system}.target}-xen.bin" $out/lib/grub-xen/ + }-${grubVariant}.bin" \ + $(ls "${if buildPvImage then grub2_xen else grub2_xen_pvh}/lib/grub/${ + efiSystemsBuild.${stdenv.hostPlatform.system}.target + }-${grubVariant}/" | grep 'mod$' | grep -v '^all_video\.mod$') + mkdir -p "$out/lib/grub-${grubVariant}" + cp "grub-${ + efiSystemsBuild.${stdenv.hostPlatform.system}.target + }-${grubVariant}.bin" $out/lib/grub-${grubVariant}/ ''; meta = with lib; { - description = "PvGrub image for use for booting PV Xen guests"; + description = + "PvGrub and PvhGrub images for use for booting PV/PVH Xen guests"; longDescription = '' - This package provides a PvGrub image for booting Para-Virtualized (PV) - Xen guests + This package provides PvGrub/PvhGrub images for booting + Paravirtualized (PV) or Paravirtualized Hardware (PVH) Xen guests ''; platforms = platforms.gnu ++ platforms.linux; }; - } -) + }) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0cf5247c29961..11c2f99f69cb8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3572,6 +3572,14 @@ with pkgs; xenPvhSupport = true; }; + grub2_pvgrub_image = callPackage ../by-name/gr/grub2-xen-images/package.nix { + buildPvImage = true; + }; + + grub2_pvhgrub_image = callPackage ../by-name/gr/grub2-xen-images/package.nix { + buildPvhImage = true; + }; + grub4dos = callPackage ../tools/misc/grub4dos { stdenv = stdenv_32bit; };