libghostty-vt: fix broken dynamic linking with pkg-config (#12364)

~`${prefix}/include` and `${prefix}/lib` are incorrect under
split-prefix installs (e.g. Nix multi-output). Use `b.h_dir` /
`b.lib_dir` instead and drop the unneeded Nix postInstall/postFixup
hooks.~

Refactors the libghostty-vt derivation to:

- fix `libdir` pointing to the wrong output in the pkg-config files.
This would throw a missing library error at runtime.
- reduce the amount of manual copying, linking, and patching of files.

An earlier version of this PR used the zig compiler + `.pc` files to do
this. People pointed out concerns, so I came up with a simpler solution.

Claude Code was used to debug and write an initial fix. Final changes
rewritten and simplified by me. No AI was used to write comments,
descriptions, etc.
pull/12374/head
Jeffrey C. Ollie 2026-04-22 10:35:02 -05:00 committed by GitHub
commit 98b7ad4c49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 12 deletions

View File

@ -69,17 +69,10 @@ stdenv.mkDerivation (finalAttrs: {
postInstall = ''
mkdir -p "$dev/lib"
mv "$out/lib/libghostty-vt.a" "$dev/lib"
rm "$out/lib/libghostty-vt.so"
mv "$out/include" "$dev"
mv "$out/share" "$dev"
ln -sf "$out/lib/libghostty-vt.so.${lib.versions.major finalAttrs.version}" "$dev/lib/libghostty-vt.so"
mv "$out/lib/libghostty-vt.a" "$dev/lib/"
'';
postFixup = ''
substituteInPlace "$dev/share/pkgconfig/libghostty-vt.pc" \
--replace-fail "$out" "$dev"
substituteInPlace "$dev/share/pkgconfig/libghostty-vt-static.pc" \
--replace-fail "$out" "$dev"
'';
@ -128,8 +121,7 @@ stdenv.mkDerivation (finalAttrs: {
runHook preBuildHooks
cc -o test test_libghostty_vt.c \
''$(pkg-config --cflags --libs libghostty-vt) \
-Wl,-rpath,"${finalAttrs.finalPackage}/lib"
''$(pkg-config --cflags --libs libghostty-vt)
runHook postBuildHooks
'';
@ -207,8 +199,7 @@ stdenv.mkDerivation (finalAttrs: {
runHook preBuildHooks
cc -o test main.c \
''$(pkg-config --cflags --libs libghostty-vt) \
-Wl,-rpath,"${finalAttrs.finalPackage}/lib"
''$(pkg-config --cflags --libs libghostty-vt)
runHook postBuildHooks
'';