@@ -0,0 +1,42 @@
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+})