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..fbe87ef0a --- /dev/null +++ b/nix/libghostty-vt.nix @@ -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; + }; +})