about summary refs log tree commit diff
path: root/pkgs/tools/misc/ipxe/default.nix
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2019-07-15 17:36:09 +0300
committerNikolay Amiantov <ab@fmap.me>2019-07-15 19:32:41 +0300
commit9e12db91de503094f41b69e9a21838c3569fbc3a (patch)
treefa2507b2a7ab5da75bb9309f6a0dd4e4e94b1609 /pkgs/tools/misc/ipxe/default.nix
parenta234b912713e0bead22e3e90ce40ade0b681d9b3 (diff)
downloadnixlib-9e12db91de503094f41b69e9a21838c3569fbc3a.tar
nixlib-9e12db91de503094f41b69e9a21838c3569fbc3a.tar.gz
nixlib-9e12db91de503094f41b69e9a21838c3569fbc3a.tar.bz2
nixlib-9e12db91de503094f41b69e9a21838c3569fbc3a.tar.lz
nixlib-9e12db91de503094f41b69e9a21838c3569fbc3a.tar.xz
nixlib-9e12db91de503094f41b69e9a21838c3569fbc3a.tar.zst
nixlib-9e12db91de503094f41b69e9a21838c3569fbc3a.zip
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.
Diffstat (limited to 'pkgs/tools/misc/ipxe/default.nix')
-rw-r--r--pkgs/tools/misc/ipxe/default.nix32
1 files changed, 20 insertions, 12 deletions
diff --git a/pkgs/tools/misc/ipxe/default.nix b/pkgs/tools/misc/ipxe/default.nix
index a9cddcc5ff81..c8668a5ad721 100644
--- a/pkgs/tools/misc/ipxe/default.nix
+++ b/pkgs/tools/misc/ipxe/default.nix
@@ -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" ];
     };
 }