@@ -0,0 +1,43 @@
1+{ stdenvNoCC, lib, glibc, musl }:
2+
3+let
4+ libc =
5+ if stdenvNoCC.targetPlatform.isMusl
6+ then musl
7+ else glibc;
8+ headerPath =
9+ if stdenvNoCC.targetPlatform.isMusl
10+ then "musl-${libc.version}/include/elf.h"
11+ else "glibc-${libc.version}/elf/elf.h";
12+in
13+
14+stdenvNoCC.mkDerivation {
15+ name = "elf-header";
16+ inherit (libc) version;
17+
18+ src = null;
19+
20+ unpackPhase = "true";
21+
22+ dontBuild = true;
23+
24+ installPhase = ''
25+ mkdir -p "$out/include";
26+ tar -xf \
27+ ${lib.escapeShellArg libc.src} \
28+ ${lib.escapeShellArg headerPath} \
29+ --to-stdout \
30+ | sed -e '/features\.h/d' \
31+ > "$out/include/elf.h"
32+ '';
33+
34+ meta = libc.meta // {
35+ description = "The datastructures of ELF according to the target platform's libc";
36+ longDescription = ''
37+ The Executable and Linkable Format (ELF, formerly named Extensible Linking
38+ Format), is usually defined in a header like this.
39+ '';
40+ platforms = lib.platforms.all;
41+ maintainers = [ lib.maintainers.ericson2314 ];
42+ };
43+}