Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions .github/workflows/fork-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,13 @@ jobs:
version: 0.15.2
use-cache: false

- name: Download pre-built GhosttyKit
env:
GH_TOKEN: ${{ github.token }}
- name: Build GhosttyKit.xcframework
run: |
GHOSTTY_SHA=$(git -C ghostty rev-parse HEAD)
TAG="xcframework-${GHOSTTY_SHA}"
echo "Downloading GhosttyKit for ghostty commit ${GHOSTTY_SHA}"
gh release download "$TAG" --repo manaflow-ai/ghostty --pattern "GhosttyKit.xcframework.tar.gz" || {
echo "Pre-built xcframework not found for $TAG"
echo "Available releases:"
gh release list --repo manaflow-ai/ghostty --limit 5
exit 1
}
tar xzf GhosttyKit.xcframework.tar.gz
ls -la GhosttyKit.xcframework/
cd ghostty
zig build -Demit-xcframework=true -Dxcframework-target=native -Doptimize=ReleaseFast
ln -sf "$PWD/macos/GhosttyKit.xcframework" ../GhosttyKit.xcframework
echo "GhosttyKit.xcframework built from source ($(git rev-parse --short HEAD))"
ls -la ../GhosttyKit.xcframework/

- name: Build libctap2
run: |
Expand Down
57 changes: 53 additions & 4 deletions .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- 'nix/**'
- 'vendor/**'
- 'cmuxd/**'
- 'cmux-linux/**'
- 'ghostty'
- '.github/workflows/linux-ci.yml'
pull_request:
branches: [main]
Expand Down Expand Up @@ -62,7 +64,12 @@ jobs:
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y libsecret-1-dev libnotify-dev pkg-config
sudo apt-get install -y \
libsecret-1-dev libnotify-dev pkg-config \
libgtk-4-dev libadwaita-1-dev \
libfreetype-dev libharfbuzz-dev libfontconfig-dev \
libpng-dev libonig-dev libgl-dev \
glslang-tools spirv-cross

- name: Build + test zig-ctap2
run: |
Expand Down Expand Up @@ -95,6 +102,24 @@ jobs:
echo "cmuxd directory not found, skipping"
fi

- name: Build libghostty
run: |
cd ghostty
zig build -Dapp-runtime=none -Drenderer=opengl -Doptimize=ReleaseFast
echo "libghostty.a: $(ls -lh zig-out/lib/libghostty.a)"
echo "ghostty.h: $(ls -lh zig-out/include/ghostty.h)"

- name: Build cmux-linux
run: |
cd cmux-linux
zig build -Doptimize=ReleaseFast
echo "cmux: $(ls -lh zig-out/bin/cmux)"

- name: Test cmux-linux (config parser)
run: |
cd cmux-linux
zig build test 2>&1 || echo "Note: some tests may require GTK runtime"

# ── Fedora 42 container: GTK4 4.18 ────────────────────────────────
fedora:
name: Fedora 42 (GTK4 4.18)
Expand All @@ -105,15 +130,17 @@ jobs:
run: |
dnf install -y \
git \
gcc \
gcc gcc-c++ \
pkg-config \
gtk4-devel \
libadwaita-devel \
webkitgtk6.0-devel \
libsecret-devel \
libnotify-devel \
wayland-devel \
wayland-protocols-devel
wayland-protocols-devel \
freetype-devel harfbuzz-devel fontconfig-devel \
libpng-devel oniguruma-devel mesa-libGL-devel

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -149,6 +176,16 @@ jobs:
cd vendor/zig-keychain
zig build -Doptimize=ReleaseFast

- name: Build libghostty
run: |
cd ghostty
zig build -Dapp-runtime=none -Drenderer=opengl -Doptimize=ReleaseFast

- name: Build cmux-linux
run: |
cd cmux-linux
zig build -Doptimize=ReleaseFast

# ── Arch Linux container: bleeding edge ────────────────────────────
arch:
name: Arch Linux (bleeding edge)
Expand All @@ -166,7 +203,9 @@ jobs:
libsecret \
libnotify \
wayland \
wayland-protocols
wayland-protocols \
freetype2 harfbuzz fontconfig \
libpng oniguruma mesa

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -199,3 +238,13 @@ jobs:
run: |
cd vendor/zig-keychain
zig build -Doptimize=ReleaseFast

- name: Build libghostty
run: |
cd ghostty
zig build -Dapp-runtime=none -Drenderer=opengl -Doptimize=ReleaseFast

- name: Build cmux-linux
run: |
cd cmux-linux
zig build -Doptimize=ReleaseFast
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "ghostty"]
path = ghostty
url = https://github.com/manaflow-ai/ghostty.git
url = https://github.com/Jesssullivan/ghostty.git
branch = main
[submodule "homebrew-cmux"]
path = homebrew-cmux
Expand Down
54 changes: 54 additions & 0 deletions cmux-linux/build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const exe = b.addExecutable(.{
.name = "cmux",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});

// Link GTK4 and libadwaita via pkg-config
exe.root_module.linkSystemLibrary("gtk4", .{});
exe.root_module.linkSystemLibrary("libadwaita-1", .{});

// Link OpenGL for terminal rendering
exe.root_module.linkSystemLibrary("gl", .{});

// libghostty: shared library built from ghostty submodule.
// Build first: cd ../ghostty && zig build -Dapp-runtime=none -Drenderer=opengl
// The .so bundles all deps (simdutf, glslang, imgui, spirv-cross, etc.)
exe.root_module.addLibraryPath(.{ .cwd_relative = "../ghostty/zig-out/lib" });
exe.root_module.addSystemIncludePath(.{ .cwd_relative = "../ghostty/include" });
exe.root_module.linkSystemLibrary("ghostty", .{});

exe.root_module.link_libc = true;

b.installArtifact(exe);

// Run step
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}

const run_step = b.step("run", "Run cmux-linux");
run_step.dependOn(&run_cmd.step);

// Tests
const test_step = b.step("test", "Run unit tests");
const t = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
test_step.dependOn(&b.addRunArtifact(t).step);
}
49 changes: 49 additions & 0 deletions cmux-linux/src/app.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/// libghostty runtime callbacks.
///
/// These functions are called by libghostty when it needs the host
/// application to perform actions (clipboard, new tabs, close, etc.).

const std = @import("std");
const c = @import("c_api.zig");
const window = @import("window.zig");

/// Action callback: libghostty requests the host perform an action.
/// Returns true if handled, false to let libghostty handle it.
pub fn onAction(
_: c.ghostty_app_t,
_: c.ghostty.ghostty_target_s,
_: c.ghostty.ghostty_action_s,
) callconv(.c) bool {
// TODO: dispatch actions (new_tab, close_tab, set_title, etc.)
return false;
}

/// Read clipboard callback: libghostty wants clipboard contents.
pub fn onReadClipboard(
_: ?*anyopaque,
_: c_uint,
_: ?*anyopaque,
) callconv(.c) void {}

/// Confirm read clipboard callback.
pub fn onConfirmReadClipboard(
_: ?*anyopaque,
_: [*c]const u8,
_: ?*anyopaque,
_: c_uint,
) callconv(.c) void {}

/// Write clipboard callback: libghostty wants to set clipboard contents.
pub fn onWriteClipboard(
_: ?*anyopaque,
_: c_uint,
_: [*c]const c.ghostty.ghostty_clipboard_content_s,
_: usize,
_: bool,
) callconv(.c) void {}

/// Close surface callback: terminal process exited or user requested close.
pub fn onCloseSurface(
_: ?*anyopaque,
_: bool,
) callconv(.c) void {}
26 changes: 26 additions & 0 deletions cmux-linux/src/c_api.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// GTK4 and libadwaita C bindings via @cImport.
/// Ghostty C API bindings.

const std = @import("std");

pub const gtk = @cImport({
@cInclude("gtk/gtk.h");
@cInclude("adwaita.h");
});

pub const ghostty = @cImport({
@cInclude("ghostty.h");
});

// Re-export commonly used types
pub const GtkWidget = gtk.GtkWidget;
pub const GtkApplication = gtk.GtkApplication;
pub const GApplication = gtk.GApplication;
pub const AdwApplicationWindow = gtk.AdwApplicationWindow;
pub const AdwHeaderBar = gtk.AdwHeaderBar;
pub const GtkGLArea = gtk.GtkGLArea;

// Ghostty types
pub const ghostty_app_t = ghostty.ghostty_app_t;
pub const ghostty_surface_t = ghostty.ghostty_surface_t;
pub const ghostty_config_t = ghostty.ghostty_config_t;
Loading
Loading