core/pkgs/by-name/gl/glibc/multi.nix

46 lines
1.1 KiB
Nix
Raw Normal View History

2024-06-30 08:12:46 +00:00
{
lib,
runCommand,
glibc,
glibc32,
2024-05-02 00:46:19 +00:00
}:
let
nameVersion = builtins.parseDrvName glibc.name;
glibc64 = glibc;
in
runCommand "${nameVersion.name}-multi-${nameVersion.version}"
# out as the first output is an exception exclusive to glibc
{
2024-06-30 08:12:46 +00:00
outputs = [
"out"
"bin"
"dev"
]; # TODO: no static version here (yet)
2024-05-02 00:46:19 +00:00
passthru = {
2024-06-30 08:12:46 +00:00
libgcc = lib.lists.filter (x: x != null) [
2024-05-02 00:46:19 +00:00
(glibc64.libgcc or null)
(glibc32.libgcc or null)
];
};
}
''
mkdir -p "$out/lib"
ln -s '${glibc64.out}'/lib/* "$out/lib"
ln -s '${glibc32.out}/lib' "$out/lib/32"
ln -s lib "$out/lib64"
# fixing ldd RLTDLIST
mkdir -p "$bin/bin"
cp -s '${glibc64.bin}'/bin/* "$bin/bin/"
rm "$bin/bin/ldd"
sed -e "s|^RTLDLIST=.*$|RTLDLIST=\"$out/lib/ld-linux-x86-64.so.2 $out/lib/32/ld-linux.so.2\"|g" \
'${glibc64.bin}/bin/ldd' > "$bin/bin/ldd"
chmod +x "$bin/bin/ldd"
mkdir "$dev"
cp -rs '${glibc32.dev}'/include "$dev/"
chmod +w -R "$dev"
cp -rsf '${glibc64.dev}'/include "$dev/"
''