aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/nix
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-07 18:29:21 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-07 18:29:21 +0300
commitdcfe11a7588fcd42471159453810abc9b7720a57 (patch)
treec32a77266028e73ca2382b96c96f8438a5fcd621 /vendor/libghostty-vt/nix
parent2dfed860103c4e4505ac7f25def9fe37da1e1e6a (diff)
build: update libghostty-vt vendor
vendor ghostty 063ac3e and remove the musl libc++ link workaround. expose the new selection formatter and hyperlink uri apis for follow-up rendering work. add manual artifact validation for static linux builds.
Diffstat (limited to 'vendor/libghostty-vt/nix')
-rw-r--r--vendor/libghostty-vt/nix/devShell.nix18
-rw-r--r--vendor/libghostty-vt/nix/libghostty-vt.nix256
-rw-r--r--vendor/libghostty-vt/nix/package.nix4
-rw-r--r--vendor/libghostty-vt/nix/test-src/test_libghostty_vt.c9
4 files changed, 249 insertions, 38 deletions
diff --git a/vendor/libghostty-vt/nix/devShell.nix b/vendor/libghostty-vt/nix/devShell.nix
index df08fc20..b530c56c 100644
--- a/vendor/libghostty-vt/nix/devShell.nix
+++ b/vendor/libghostty-vt/nix/devShell.nix
@@ -12,7 +12,7 @@
#, glxinfo # unused
ncurses,
nodejs,
- nodePackages,
+ prettier,
oniguruma,
parallel,
pkg-config,
@@ -109,7 +109,7 @@ in
nodejs
# Linting
- nodePackages.prettier
+ prettier
alejandra
pinact
typos
@@ -227,8 +227,22 @@ in
unset SDKROOT
unset DEVELOPER_DIR
+ # AFL++ needs to use the Homebrew/system Apple toolchain directly.
+ # The Nix compiler wrapper variables leak a Nix linker into afl-cc,
+ # which breaks even trivial fuzz harness links on macOS.
+ unset NIX_CC
+ unset NIX_CFLAGS_COMPILE
+ unset NIX_LDFLAGS
+ unset LD
+ unset CC
+ unset CXX
+ unset CFLAGS
+ unset CPPFLAGS
+ unset LDFLAGS
+
# We need to remove "xcrun" from the PATH. It is injected by
# some dependency but we need to rely on system Xcode tools
export PATH=$(echo "$PATH" | awk -v RS=: -v ORS=: '$0 !~ /xcrun/ || $0 == "/usr/bin" {print}' | sed 's/:$//')
+ export PATH="/opt/homebrew/opt/llvm/bin:/opt/homebrew/bin:/usr/local/opt/llvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
'');
}
diff --git a/vendor/libghostty-vt/nix/libghostty-vt.nix b/vendor/libghostty-vt/nix/libghostty-vt.nix
index fbe87ef0..2b67fc83 100644
--- a/vendor/libghostty-vt/nix/libghostty-vt.nix
+++ b/vendor/libghostty-vt/nix/libghostty-vt.nix
@@ -1,30 +1,32 @@
{
- lib,
- stdenv,
callPackage,
git,
+ lib,
+ llvmPackages,
pkg-config,
+ runCommand,
+ stdenv,
+ testers,
+ fixDarwinDylibNames,
+ versionCheckHook,
+ darwin,
+ xcbuild,
zig_0_15,
revision ? "dirty",
optimize ? "Debug",
+ simd ? true,
}:
stdenv.mkDerivation (finalAttrs: {
- pname = "ghostty";
- version = "0.1.0-dev";
+ pname = "libghostty-vt";
+ version = "0.1.0-dev+${revision}-nix";
# We limit source like this to try and reduce the amount of rebuilds as possible
- # thus we only provide the source that is needed for the build
- #
- # NOTE: as of the current moment only linux files are provided,
- # since darwin support is not finished
+ # thus we only provide the source that is needed for the build.
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.intersection (lib.fileset.fromSource (lib.sources.cleanSource ../.)) (
lib.fileset.unions [
- ../dist/linux
- ../images
../include
- ../po
../pkg
../src
../vendor
@@ -35,27 +37,56 @@ stdenv.mkDerivation (finalAttrs: {
);
};
- deps = callPackage ../build.zig.zon.nix {name = "ghostty-cache-${finalAttrs.version}";};
+ # Zig's build runner computes relative paths from `cwd` to the build directory.
+ # The logic is purely lexical, so if the `cwd` is a symlink that resolves to a different depth during `chdir`, the computed path becomes incorrect.
+ #
+ # See: https://codeberg.org/ziglang/zig/issues/32121
+ #
+ # Workaround: override `linkFarm` with a copy-farm so deps are real directories, not symlinks.
+ deps = callPackage ../build.zig.zon.nix {
+ name = "${finalAttrs.pname}-cache-${finalAttrs.version}";
+ linkFarm = name: entries:
+ runCommand name {} ''
+ mkdir -p $out
+ ${lib.concatMapStringsSep "\n" (e: ''
+ cp -rL ${e.path} $out/${e.name}
+ '')
+ entries}
+ '';
+ };
- nativeBuildInputs = [
- git
- pkg-config
- zig_0_15
- ];
+ nativeBuildInputs =
+ [
+ git
+ pkg-config
+ zig_0_15
+ ]
+ ++ lib.optionals stdenv.hostPlatform.isDarwin [
+ darwin.cctools
+ fixDarwinDylibNames
+ xcbuild
+ ];
buildInputs = [];
+ doCheck = false;
dontSetZigDefaultFlags = true;
- zigBuildFlags = [
- "--system"
- "${finalAttrs.deps}"
- "-Dversion-string=${finalAttrs.version}-${revision}-nix"
- "-Dcpu=baseline"
- "-Doptimize=${optimize}"
- "-Dapp-runtime=none"
- "-Demit-lib-vt=true"
- ];
+ zigBuildFlags =
+ [
+ "--system"
+ "${finalAttrs.deps}"
+ "-Dlib-version-string=${finalAttrs.version}"
+ "-Dcpu=baseline"
+ "-Doptimize=${optimize}"
+ "-Dapp-runtime=none"
+ "-Demit-lib-vt=true"
+ "-Dsimd=${lib.boolToString simd}"
+ ]
+ ++ lib.optionals stdenv.hostPlatform.isDarwin [
+ "-Demit-xcframework=false"
+ ];
+ zigCheckFlags = finalAttrs.zigBuildFlags ++ ["test-lib-vt"];
outputs = [
"out"
@@ -64,22 +95,179 @@ 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.0" "$dev/lib/libghostty-vt.so"
+ mv "$out/lib/libghostty-vt.a" "$dev/lib/"
'';
postFixup = ''
- substituteInPlace "$dev/share/pkgconfig/libghostty-vt.pc" \
- --replace "$out" "$dev"
+ substituteInPlace "$dev/share/pkgconfig/libghostty-vt-static.pc" \
+ --replace-fail "$out" "$dev"
'';
+ passthru.tests = let
+ sharedExt = stdenv.hostPlatform.extensions.sharedLibrary;
+ sharedLibName = version:
+ if stdenv.hostPlatform.isDarwin
+ then "libghostty-vt.${version}${sharedExt}"
+ else "libghostty-vt${sharedExt}.${version}";
+ linkCheck = bin: pat:
+ if stdenv.hostPlatform.isDarwin
+ then ''otool -L "${bin}" | grep -q ${pat}''
+ else ''ldd "${bin}" 2>/dev/null | grep -q ${pat}'';
+ in {
+ sanity-check = let
+ version = "${lib.versions.major finalAttrs.version}.${lib.versions.minor finalAttrs.version}.${lib.versions.patch finalAttrs.version}";
+ in
+ runCommand "sanity-check" {} (builtins.concatStringsSep "\n" [
+ ''
+ set +o pipefail
+ ${lib.getExe' stdenv.cc "nm"} "${finalAttrs.finalPackage}/lib/${sharedLibName version}" | grep -qE 'T _?ghostty_terminal_new'
+ ${lib.getExe' stdenv.cc "nm"} "${finalAttrs.finalPackage.dev}/lib/libghostty-vt.a" | grep -qE 'T _?ghostty_terminal_new'
+ ''
+ (
+ lib.optionalString simd
+ ''
+ ${lib.getExe' stdenv.cc "nm"} "${finalAttrs.finalPackage.dev}/lib/libghostty-vt.a" | grep -q 'T .*simdutf'
+ ${lib.getExe' stdenv.cc "nm"} "${finalAttrs.finalPackage.dev}/lib/libghostty-vt.a" | grep -q 'T .*3hwy'
+ ''
+ )
+ ''
+ touch "$out"
+ ''
+ ]);
+ pkg-config = testers.hasPkgConfigModules {
+ package = finalAttrs.finalPackage.dev;
+ };
+ pkg-config-libs =
+ runCommand "pkg-config-libs" {
+ nativeBuildInputs = [pkg-config];
+ } ''
+ export PKG_CONFIG_PATH="${finalAttrs.finalPackage.dev}/share/pkgconfig"
+
+ pkg-config --libs --static libghostty-vt | grep -q -- '-lghostty-vt'
+ pkg-config --libs --static libghostty-vt-static | grep -q -- '${finalAttrs.finalPackage.dev}/lib/libghostty-vt.a'
+
+ touch "$out"
+ '';
+ build-with-shared = stdenv.mkDerivation {
+ name = "build-with-shared";
+ src = ./test-src;
+ doInstallCheck = true;
+ nativeBuildInputs = [pkg-config];
+ buildInputs = [finalAttrs.finalPackage];
+ buildPhase = ''
+ runHook preBuildHooks
+
+ cc -o test test_libghostty_vt.c \
+ ''$(pkg-config --cflags --libs libghostty-vt)
+
+ runHook postBuildHooks
+ '';
+ installPhase = ''
+ runHook preInstallHooks
+
+ mkdir -p "$out/bin";
+ cp -a test "$out/bin/test";
+
+ runHook postInstallHooks
+ '';
+ installCheckPhase = ''
+ runHook preInstallCheckHooks
+
+ "$out/bin/test" | grep -q "SIMD: ${
+ if simd
+ then "yes"
+ else "no"
+ }"
+ ${linkCheck "$out/bin/test" "libghostty-vt"}
+
+ runHook postInstallCheckHooks
+ '';
+ meta = {
+ mainProgram = "test";
+ };
+ };
+ build-with-static = stdenv.mkDerivation {
+ name = "build-with-static";
+ src = ./test-src;
+ doInstallCheck = true;
+ nativeBuildInputs = [pkg-config];
+ buildInputs = [finalAttrs.finalPackage llvmPackages.libcxxClang];
+ buildPhase = ''
+ runHook preBuildHooks
+
+ cc -o test test_libghostty_vt.c \
+ ''$(pkg-config --cflags --libs --static libghostty-vt-static)
+
+ runHook postBuildHooks
+ '';
+ installPhase = ''
+ runHook preInstallHooks
+
+ mkdir -p "$out/bin";
+ cp -a test "$out/bin/test";
+
+ runHook postInstallHooks
+ '';
+ installCheckPhase = ''
+ runHook preInstallCheckHooks
+
+ "$out/bin/test" | grep -q "SIMD: ${
+ if simd
+ then "yes"
+ else "no"
+ }"
+ ! ${linkCheck "$out/bin/test" "libghostty-vt"}
+
+ runHook postInstallCheckHooks
+ '';
+ meta = {
+ mainProgram = "test";
+ };
+ };
+ build-example-c-vt-build-info = stdenv.mkDerivation {
+ name = "build-example-c-vt-build-info";
+ version = finalAttrs.version;
+ src = ../example/c-vt-build-info/src;
+ doInstallCheck = true;
+ nativeBuildInputs = [pkg-config];
+ nativeInstallCheckInputs = [versionCheckHook];
+ buildInputs = [finalAttrs.finalPackage];
+ buildPhase = ''
+ runHook preBuildHooks
+
+ cc -o test main.c \
+ ''$(pkg-config --cflags --libs libghostty-vt)
+
+ runHook postBuildHooks
+ '';
+ installPhase = ''
+ runHook preInstallHooks
+
+ mkdir -p "$out/bin";
+ cp -a test "$out/bin/test";
+
+ runHook postInstallHooks
+ '';
+ installCheckPhase = ''
+ runHook preInstallCheckHooks
+
+ ${linkCheck "$out/bin/test" "libghostty-vt"}
+
+ runHook postInstallCheckHooks
+ '';
+ meta = {
+ mainProgram = "test";
+ };
+ };
+ };
+
meta = {
homepage = "https://ghostty.org";
license = lib.licenses.mit;
platforms = zig_0_15.meta.platforms;
+ pkgConfigModules = [
+ "libghostty-vt"
+ "libghostty-vt-static"
+ ];
};
})
diff --git a/vendor/libghostty-vt/nix/package.nix b/vendor/libghostty-vt/nix/package.nix
index 8287b088..fd952c9d 100644
--- a/vendor/libghostty-vt/nix/package.nix
+++ b/vendor/libghostty-vt/nix/package.nix
@@ -30,7 +30,7 @@
in
stdenv.mkDerivation (finalAttrs: {
pname = "ghostty";
- version = "1.3.2-dev";
+ version = "1.3.2-dev+${revision}-nix";
# We limit source like this to try and reduce the amount of rebuilds as possible
# thus we only provide the source that is needed for the build
@@ -86,7 +86,7 @@ in
zigBuildFlags = [
"--system"
"${finalAttrs.deps}"
- "-Dversion-string=${finalAttrs.version}-${revision}-nix"
+ "-Dversion-string=${finalAttrs.version}"
"-Dgtk-x11=${lib.boolToString enableX11}"
"-Dgtk-wayland=${lib.boolToString enableWayland}"
"-Dcpu=baseline"
diff --git a/vendor/libghostty-vt/nix/test-src/test_libghostty_vt.c b/vendor/libghostty-vt/nix/test-src/test_libghostty_vt.c
new file mode 100644
index 00000000..dc258629
--- /dev/null
+++ b/vendor/libghostty-vt/nix/test-src/test_libghostty_vt.c
@@ -0,0 +1,9 @@
+#include <ghostty/vt.h>
+#include <stdio.h>
+int main(void) {
+ bool simd = false;
+ GhosttyResult r = ghostty_build_info(GHOSTTY_BUILD_INFO_SIMD, &simd);
+ if (r != GHOSTTY_SUCCESS) return 1;
+ printf("SIMD: %s\n", simd ? "yes" : "no");
+ return 0;
+}