fork
Configure Feed
Select the types of activity you want to include in your feed.
lol
fork
Configure Feed
Select the types of activity you want to include in your feed.
1{ stdenv, lib, fetchFromGitHub, unstableGitUpdater, buildPackages
2, gnu-efi, mtools, openssl, perl, xorriso, xz
3, syslinux ? null
4, embedScript ? null
5, additionalTargets ? {}
6, additionalOptions ? []
7}:
8
9let
10 targets = additionalTargets // lib.optionalAttrs stdenv.isx86_64 {
11 "bin-x86_64-efi/ipxe.efi" = null;
12 "bin-x86_64-efi/ipxe.efirom" = null;
13 "bin-x86_64-efi/ipxe.usb" = "ipxe-efi.usb";
14 "bin-x86_64-efi/snp.efi" = null;
15 } // lib.optionalAttrs stdenv.hostPlatform.isx86 {
16 "bin/ipxe.dsk" = null;
17 "bin/ipxe.usb" = null;
18 "bin/ipxe.iso" = null;
19 "bin/ipxe.lkrn" = null;
20 "bin/undionly.kpxe" = null;
21 } // lib.optionalAttrs stdenv.isAarch32 {
22 "bin-arm32-efi/ipxe.efi" = null;
23 "bin-arm32-efi/ipxe.efirom" = null;
24 "bin-arm32-efi/ipxe.usb" = "ipxe-efi.usb";
25 "bin-arm32-efi/snp.efi" = null;
26 } // lib.optionalAttrs stdenv.isAarch64 {
27 "bin-arm64-efi/ipxe.efi" = null;
28 "bin-arm64-efi/ipxe.efirom" = null;
29 "bin-arm64-efi/ipxe.usb" = "ipxe-efi.usb";
30 "bin-arm64-efi/snp.efi" = null;
31 };
32in
33
34stdenv.mkDerivation rec {
35 pname = "ipxe";
36 version = "1.21.1-unstable-2024-04-17";
37
38 nativeBuildInputs = [ gnu-efi mtools openssl perl xorriso xz ] ++ lib.optional stdenv.hostPlatform.isx86 syslinux;
39 depsBuildBuild = [ buildPackages.stdenv.cc ];
40
41 strictDeps = true;
42
43 src = fetchFromGitHub {
44 owner = "ipxe";
45 repo = "ipxe";
46 rev = "d7e58c5a812988c341ec4ad19f79faf067388d58";
47 hash = "sha256-OIisRd2o2zrTqH1Xv3FDhQWDqhKNeGhPkHWyYZzbtTU=";
48 };
49
50 postPatch = lib.optionalString stdenv.hostPlatform.isAarch64 ''
51 substituteInPlace src/util/genfsimg --replace " syslinux " " true "
52 ''; # calling syslinux on a FAT image isn't going to work
53
54 # not possible due to assembler code
55 hardeningDisable = [ "pic" "stackprotector" ];
56
57 env.NIX_CFLAGS_COMPILE = "-Wno-error";
58
59 makeFlags =
60 [ "ECHO_E_BIN_ECHO=echo" "ECHO_E_BIN_ECHO_E=echo" # No /bin/echo here.
61 "CROSS=${stdenv.cc.targetPrefix}"
62 ] ++ lib.optional (embedScript != null) "EMBED=${embedScript}";
63
64
65 enabledOptions = [
66 "PING_CMD"
67 "IMAGE_TRUST_CMD"
68 "DOWNLOAD_PROTO_HTTP"
69 "DOWNLOAD_PROTO_HTTPS"
70 ] ++ additionalOptions;
71
72 configurePhase = ''
73 runHook preConfigure
74 for opt in ${lib.escapeShellArgs enabledOptions}; do echo "#define $opt" >> src/config/general.h; done
75 substituteInPlace src/Makefile.housekeeping --replace '/bin/echo' echo
76 '' + lib.optionalString stdenv.hostPlatform.isx86 ''
77 substituteInPlace src/util/genfsimg --replace /usr/lib/syslinux ${syslinux}/share/syslinux
78 '' + ''
79 runHook postConfigure
80 '';
81
82 preBuild = "cd src";
83
84 buildFlags = lib.attrNames targets;
85
86 installPhase = ''
87 runHook preInstall
88
89 mkdir -p $out
90 ${lib.concatStringsSep "\n" (lib.mapAttrsToList (from: to:
91 if to == null
92 then "cp -v ${from} $out"
93 else "cp -v ${from} $out/${to}") targets)}
94
95 # Some PXE constellations especially with dnsmasq are looking for the file with .0 ending
96 # let's provide it as a symlink to be compatible in this case.
97 ln -s undionly.kpxe $out/undionly.kpxe.0
98
99 runHook postInstall
100 '';
101
102 enableParallelBuilding = true;
103
104 passthru.updateScript = unstableGitUpdater {
105 tagPrefix = "v";
106 };
107
108 meta = with lib;
109 { description = "Network boot firmware";
110 homepage = "https://ipxe.org/";
111 license = licenses.gpl2Only;
112 platforms = platforms.linux;
113 };
114}