add a nix package (with CI tests) for libghostty-vt (#12090)

This commit is contained in:
Mitchell Hashimoto
2026-04-03 20:12:52 -07:00
committed by GitHub
3 changed files with 103 additions and 0 deletions

View File

@@ -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

View File

@@ -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);

85
nix/libghostty-vt.nix Normal file
View File

@@ -0,0 +1,85 @@
{
lib,
stdenv,
callPackage,
git,
pkg-config,
zig_0_15,
revision ? "dirty",
optimize ? "Debug",
}:
stdenv.mkDerivation (finalAttrs: {
pname = "ghostty";
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
#
# 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"
];
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 = zig_0_15.meta.platforms;
};
})