summary refs log tree commit diff
path: root/pkgs/tools
diff options
context:
space:
mode:
authorMichał Pałka <michal.palka@chalmers.se>2017-05-12 06:34:38 +0000
committerMichał Pałka <michal.palka@chalmers.se>2017-07-05 12:23:30 +0000
commit55208cc2e18bf40a76e6c9ae7c16108d80fed666 (patch)
treee5113dcc932b01e96f187ff401c9f2386378ce92 /pkgs/tools
parentd15e20f9c9f974003b34e8a45689c1de99a9deec (diff)
downloadnixpkgs-55208cc2e18bf40a76e6c9ae7c16108d80fed666.tar
nixpkgs-55208cc2e18bf40a76e6c9ae7c16108d80fed666.tar.gz
nixpkgs-55208cc2e18bf40a76e6c9ae7c16108d80fed666.tar.bz2
nixpkgs-55208cc2e18bf40a76e6c9ae7c16108d80fed666.tar.lz
nixpkgs-55208cc2e18bf40a76e6c9ae7c16108d80fed666.tar.xz
nixpkgs-55208cc2e18bf40a76e6c9ae7c16108d80fed666.tar.zst
nixpkgs-55208cc2e18bf40a76e6c9ae7c16108d80fed666.zip
pvgrub_image: add package
Add a package containing a pvgrub image for xen generated from grub2
Diffstat (limited to 'pkgs/tools')
-rw-r--r--pkgs/tools/misc/grub/2.0x.nix5
-rw-r--r--pkgs/tools/misc/grub/pvgrub_image/configs/grub-bootstrap.cfg1
-rw-r--r--pkgs/tools/misc/grub/pvgrub_image/configs/grub.cfg10
-rw-r--r--pkgs/tools/misc/grub/pvgrub_image/default.nix42
4 files changed, 57 insertions, 1 deletions
diff --git a/pkgs/tools/misc/grub/2.0x.nix b/pkgs/tools/misc/grub/2.0x.nix
index 7a70f2bdbff..2bbeea8133e 100644
--- a/pkgs/tools/misc/grub/2.0x.nix
+++ b/pkgs/tools/misc/grub/2.0x.nix
@@ -3,6 +3,7 @@
 , zfs ? null
 , efiSupport ? false
 , zfsSupport ? true
+, xenSupport ? false
 }:
 
 with stdenv.lib;
@@ -46,6 +47,7 @@ in (
 
 assert efiSupport -> canEfi;
 assert zfsSupport -> zfs != null;
+assert !(efiSupport && xenSupport);
 
 stdenv.mkDerivation rec {
   name = "grub-${version}";
@@ -98,7 +100,8 @@ stdenv.mkDerivation rec {
   patches = [ ./fix-bash-completion.patch ];
 
   configureFlags = optional zfsSupport "--enable-libzfs"
-    ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.system}.target}" "--program-prefix=" ];
+    ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.system}.target}" "--program-prefix=" ]
+    ++ optionals xenSupport [ "--with-platform=xen" "--target=${efiSystemsBuild.${stdenv.system}.target}"];
 
   # save target that grub is compiled for
   grubTarget = if efiSupport
diff --git a/pkgs/tools/misc/grub/pvgrub_image/configs/grub-bootstrap.cfg b/pkgs/tools/misc/grub/pvgrub_image/configs/grub-bootstrap.cfg
new file mode 100644
index 00000000000..e9883149ab5
--- /dev/null
+++ b/pkgs/tools/misc/grub/pvgrub_image/configs/grub-bootstrap.cfg
@@ -0,0 +1 @@
+normal (memdisk)/grub.cfg
diff --git a/pkgs/tools/misc/grub/pvgrub_image/configs/grub.cfg b/pkgs/tools/misc/grub/pvgrub_image/configs/grub.cfg
new file mode 100644
index 00000000000..69115b7101c
--- /dev/null
+++ b/pkgs/tools/misc/grub/pvgrub_image/configs/grub.cfg
@@ -0,0 +1,10 @@
+# The parentheses around ${root} here to match Grub's config file syntax
+if search -s -f /boot/grub/grub.cfg ; then
+        echo "Reading (${root})/boot/grub/grub.cfg"
+	configfile /boot/grub/grub.cfg
+fi
+
+if search -s -f /grub/grub.cfg ; then
+	echo "Reading (${root})/grub/grub.cfg"
+	configfile /grub/grub.cfg
+fi
diff --git a/pkgs/tools/misc/grub/pvgrub_image/default.nix b/pkgs/tools/misc/grub/pvgrub_image/default.nix
new file mode 100644
index 00000000000..ee6e5065f40
--- /dev/null
+++ b/pkgs/tools/misc/grub/pvgrub_image/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, grub2_xen }:
+
+with stdenv.lib;
+let
+  efiSystemsBuild = {
+    "i686-linux".target = "i386";
+    "x86_64-linux".target = "x86_64";
+    "aarch64-linux".target = "aarch64";
+  };
+
+in (
+
+stdenv.mkDerivation rec {
+  name = "pvgrub-image";
+
+  configs = ./configs;
+
+  buildInputs = [ grub2_xen ];
+
+  buildCommand = ''
+    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.system}.target}-xen" -c grub-bootstrap.cfg \
+      -m memdisk.tar -o "grub-${efiSystemsBuild.${stdenv.system}.target}-xen.bin" \
+      $(ls "${grub2_xen}/lib/grub/${efiSystemsBuild.${stdenv.system}.target}-xen/" |grep 'mod''$'|grep -v '^all_video\.mod''$')
+    mkdir -p "$out/lib/grub-xen"
+    cp "grub-${efiSystemsBuild.${stdenv.system}.target}-xen.bin" $out/lib/grub-xen/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "PvGrub image for use for booting PV Xen guests";
+
+    longDescription =
+      '' This package provides a PvGrub image for booting Para-Virtualized (PV)
+         Xen guests
+      '';
+
+    platforms = platforms.gnu;
+  };
+})