From 4f825e87f5f848347669e18e507aea91b1fb26ab Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Fri, 3 Apr 2026 16:28:21 -0500 Subject: [PATCH 1/2] add a nix package (with CI tests) for libghostty-vt --- .github/workflows/test.yml | 12 +++++++ flake.nix | 6 ++++ nix/libghostty-vt.nix | 68 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 nix/libghostty-vt.nix diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 587e2ed70..b60685c5e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -653,6 +653,18 @@ jobs: - name: Check to see if the binary has not been stripped run: nm result/bin/.ghostty-wrapped 2>&1 | grep -q 'main_ghostty.main' + - name: Test ReleaseFast build of libghostty-vt + run: nix build .#libghostty-vt-releasefast + + - name: Check to see if the library looks sane + run: nm result/lib/libghostty-vt.so.0.1.0 2>&1 | grep -q 'ghostty_terminal_new' + + - name: Test Debug build of libghostty-vt + run: nix build .#libghostty-vt-debug + + - name: Check to see if the library looks sane + run: nm result/lib/libghostty-vt.so.0.1.0 2>&1 | grep -q 'ghostty_terminal_new' + build-dist: runs-on: namespace-profile-ghostty-sm needs: test diff --git a/flake.nix b/flake.nix index fec675cf0..59ced2def 100644 --- a/flake.nix +++ b/flake.nix @@ -102,6 +102,12 @@ ghostty = ghostty-releasefast; default = ghostty; + + libghostty-vt-debug = pkgs.callPackage ./nix/libghostty-vt.nix (mkPkgArgs "Debug"); + libghostty-vt-releasesafe = pkgs.callPackage ./nix/libghostty-vt.nix (mkPkgArgs "ReleaseSafe"); + libghostty-vt-releasefast = pkgs.callPackage ./nix/libghostty-vt.nix (mkPkgArgs "ReleaseFast"); + + libghostty-vt = libghostty-vt-releasefast; }); formatter = forAllPlatforms (pkgs: pkgs.alejandra); diff --git a/nix/libghostty-vt.nix b/nix/libghostty-vt.nix new file mode 100644 index 000000000..e1c0a1a8f --- /dev/null +++ b/nix/libghostty-vt.nix @@ -0,0 +1,68 @@ +{ + lib, + stdenv, + callPackage, + git, + pkg-config, + zig_0_15, + revision ? "dirty", + optimize ? "Debug", +}: +stdenv.mkDerivation (finalAttrs: { + pname = "ghostty"; + version = "1.3.2-dev"; + + # 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 + 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 + ../build.zig + ../build.zig.zon + ../build.zig.zon.nix + ] + ); + }; + + deps = callPackage ../build.zig.zon.nix {name = "ghostty-cache-${finalAttrs.version}";}; + + nativeBuildInputs = [ + git + pkg-config + zig_0_15 + ]; + + buildInputs = []; + + dontSetZigDefaultFlags = true; + + zigBuildFlags = [ + "--system" + "${finalAttrs.deps}" + "-Dversion-string=${finalAttrs.version}-${revision}-nix" + "-Dcpu=baseline" + "-Doptimize=${optimize}" + "-Dapp-runtime=none" + "-Demit-lib-vt=true" + ]; + + meta = { + homepage = "https://ghostty.org"; + license = lib.licenses.mit; + platforms = [ + "x86_64-linux" + "aarch64-linux" + ]; + }; +}) From 326178adb80db39dc9e62a8c58740dc2cac3c061 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Fri, 3 Apr 2026 20:19:50 -0500 Subject: [PATCH 2/2] nix: address review comments * split out dev subpackage * change version number to 0.1.0 * supported on same platforms as Zig --- nix/libghostty-vt.nix | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/nix/libghostty-vt.nix b/nix/libghostty-vt.nix index e1c0a1a8f..fbe87ef0a 100644 --- a/nix/libghostty-vt.nix +++ b/nix/libghostty-vt.nix @@ -10,7 +10,7 @@ }: stdenv.mkDerivation (finalAttrs: { pname = "ghostty"; - version = "1.3.2-dev"; + version = "0.1.0-dev"; # 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 @@ -57,12 +57,29 @@ stdenv.mkDerivation (finalAttrs: { "-Demit-lib-vt=true" ]; + outputs = [ + "out" + "dev" + ]; + + 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" + ''; + + postFixup = '' + substituteInPlace "$dev/share/pkgconfig/libghostty-vt.pc" \ + --replace "$out" "$dev" + ''; + meta = { homepage = "https://ghostty.org"; license = lib.licenses.mit; - platforms = [ - "x86_64-linux" - "aarch64-linux" - ]; + platforms = zig_0_15.meta.platforms; }; })