@@ -0,0 +1,47 @@
1+{ stdenv, fetchFromGitHub, fetchpatch, libbfd, zlib, libiberty }:
2+
3+stdenv.mkDerivation rec {
4+ pname = "wimboot";
5+ version = "2.6.0";
6+
7+ src = fetchFromGitHub {
8+ owner = "ipxe";
9+ repo = "wimboot";
10+ rev = "v${version}";
11+ sha256 = "134wqqr147az5vbj4szd0xffwa99b4rar7w33zm3119zsn7sd79k";
12+ };
13+
14+ NIX_CFLAGS_COMPILE = "-Wno-address-of-packed-member"; # Fails on gcc9
15+
16+ patches = [
17+ # Fix for newer binutils
18+ (fetchpatch {
19+ url =
20+ "https://github.com/ipxe/wimboot/commit/91be50c17d4d9f463109d5baafd70f9fdadd86db.patch";
21+ sha256 = "113448n49hmk8nz1dxbhxiciwl281zwalvb8z5p9xfnjvibj8274";
22+ })
23+ ];
24+
25+ # We cannot use sourceRoot because the patch wouldn't apply
26+ postPatch = ''
27+ cd src
28+ '';
29+
30+ hardeningDisable = [ "pic" ];
31+
32+ buildInputs = [ libbfd zlib libiberty ];
33+ makeFlags = [ "wimboot.x86_64.efi" ];
34+
35+ installPhase = ''
36+ mkdir -p $out/share/wimboot/
37+ cp wimboot.x86_64.efi $out/share/wimboot
38+ '';
39+
40+ meta = with stdenv.lib; {
41+ homepage = "https://ipxe.org/wimboot";
42+ description = "Windows Imaging Format bootloader";
43+ license = licenses.gpl2;
44+ maintainers = with maintainers; [ das_j ajs124 ];
45+ platforms = platforms.x86; # Fails on aarch64
46+ };
47+}