summary refs log tree commit diff
path: root/pkgs/tools/misc/grub/pvgrub_image/default.nix
blob: d6aba812405c9c2733a7708eeb06a997246ea532 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ lib, stdenv, grub2_xen }:

with 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.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/${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/
  '';

  meta = with 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 ++ platforms.linux;
  };
})