git.iko.soy/typeable/nixpkgs
on master help sign in
pvgrub_image: add package

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

commit55208cc2e18bf40a76e6c9ae7c16108d80fed666 authorMichał Pałka <michal.palka@chalmers.se> dateFri 12 May 2017, 06:34 (10 years ago) parentd15e20f
5 files changed+63−1
pkgs/tools/misc/grub/2.0x.nix+4−1 pkgs/tools/misc/grub/pvgrub_image/configs/grub-bootstrap.cfg+1 pkgs/tools/misc/grub/pvgrub_image/configs/grub.cfg+10 pkgs/tools/misc/grub/pvgrub_image/default.nix+42 pkgs/top-level/all-packages.nix+6
pkgs/tools/misc/grub/2.0x.nix+4−1
@@ -3,6 +3,7 @@
33, zfs ? null
44, efiSupport ? false
55, zfsSupport ? true
6+, xenSupport ? false
67}:
78
89with stdenv.lib;
@@ -46,6 +47,7 @@ in (
4647
4748assert efiSupport -> canEfi;
4849assert zfsSupport -> zfs != null;
50+assert !(efiSupport && xenSupport);
4951
5052stdenv.mkDerivation rec {
5153 name = "grub-${version}";
@@ -98,7 +100,8 @@ stdenv.mkDerivation rec {
98100 patches = [ ./fix-bash-completion.patch ];
99101
100102 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}"];
102105
103106 # save target that grub is compiled for
104107 grubTarget = if efiSupport
pkgs/tools/misc/grub/pvgrub_image/configs/grub-bootstrap.cfgnew file+1
@@ -0,0 +1 @@
1+normal (memdisk)/grub.cfg
pkgs/tools/misc/grub/pvgrub_image/configs/grub.cfgnew file+10
@@ -0,0 +1,10 @@
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
pkgs/tools/misc/grub/pvgrub_image/default.nixnew file+42
@@ -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+})
pkgs/top-level/all-packages.nix+6
@@ -2258,6 +2258,12 @@ with pkgs;
22582258 zfsSupport = false;
22592259 };
22602260
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+
22612267 grub4dos = callPackage ../tools/misc/grub4dos {
22622268 stdenv = stdenv_32bit;
22632269 };