ipxe: support renaming targets and add several

This allows to build several targets with conflicting names.
UEFI version of USB image is now built, and so is option ROM.
This commit is contained in:
Nikolay Amiantov 2019-07-15 17:36:09 +03:00
parent a234b91271
commit 9e12db91de

View file

@ -1,23 +1,28 @@
{ stdenv, lib, fetchgit, perl, cdrkit, syslinux, xz, openssl, gnu-efi
{ stdenv, lib, fetchgit, perl, cdrkit, syslinux, xz, openssl, gnu-efi, mtools
, embedScript ? null
, additionalTargets ? {}
}:
let
date = "20190318";
rev = "ebf2eaf515e46abd43bc798e7e4ba77bfe529218";
targets = (lib.optional stdenv.isx86_64 "bin-x86_64-efi/ipxe.efi") ++ [
"bin/ipxe.dsk"
"bin/ipxe.usb"
"bin/ipxe.iso"
"bin/ipxe.lkrn"
"bin/undionly.kpxe"
];
targets = additionalTargets // lib.optionalAttrs stdenv.isx86_64 {
"bin-x86_64-efi/ipxe.efi" = null;
"bin-x86_64-efi/ipxe.efirom" = null;
"bin-x86_64-efi/ipxe.usb" = "ipxe-efi.usb";
} // {
"bin/ipxe.dsk" = null;
"bin/ipxe.usb" = null;
"bin/ipxe.iso" = null;
"bin/ipxe.lkrn" = null;
"bin/undionly.kpxe" = null;
};
in
stdenv.mkDerivation {
name = "ipxe-${date}-${builtins.substring 0 7 rev}";
buildInputs = [ perl cdrkit syslinux xz openssl gnu-efi ];
nativeBuildInputs = [ perl cdrkit syslinux xz openssl gnu-efi mtools ];
src = fetchgit {
url = https://git.ipxe.org/ipxe.git;
@ -49,11 +54,14 @@ stdenv.mkDerivation {
preBuild = "cd src";
buildFlags = targets;
buildFlags = lib.attrNames targets;
installPhase = ''
mkdir -p $out
cp ${lib.concatStringsSep " " targets} $out
${lib.concatStringsSep "\n" (lib.mapAttrsToList (from: to:
if to == null
then "cp -v ${from} $out"
else "cp -v ${from} $out/${to}") targets)}
# Some PXE constellations especially with dnsmasq are looking for the file with .0 ending
# let's provide it as a symlink to be compatible in this case.
@ -67,6 +75,6 @@ stdenv.mkDerivation {
homepage = http://ipxe.org/;
license = licenses.gpl2;
maintainers = with maintainers; [ ehmry ];
platforms = platforms.all;
platforms = [ "x86_64-linux" "i686-linux" ];
};
}