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
commit
98b7ad4c49
|
|
@ -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
|
||||
'';
|
||||
|
|
|
|||
Loading…
Reference in New Issue