Packaging ghostty terminal

  • Open
  • quality assurance status badge
Details
4 participants
  • boogs
  • Frank J. Cameron
  • Tobias Geerinckx-Rice
  • Murilo
Owner
unassigned
Submitted by
boogs
Severity
normal
Merged with
B
(address . bug-guix@gnu.org)
8734i3nsea.fsf@venatores.group
Hi,
I'm looking to package the ghostty terminal (https://ghostty.org/docs/install/build)but I ran into an issue with the zig build system pertaining to the dependencies?

I've attached the package definition including the error output below. I would appreciate some pointers here please.
(define-module (boogs packages) #:use-module (guix build-system zig) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix licenses) #:use-module (guix packages) #:use-module (gnu packages glib) #:use-module (gnu packages zig-xyz) #:use-module (gnu packages gnome) #:use-module (gnu packages gtk) #:use-module (gnu packages pkg-config) #:use-module (gnu packages zig) #:use-module (srfi srfi-1)) (define-public ghostty (let* ((version "1.0.0") (commit (string-append "v" version))) (package (name "ghostty") (version version) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/ghostty-org/ghostty.git") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "0cs1n7qddy2487hbw72v0h23ybdmp25cag00q46pk0czi5kkawh0")))) (build-system zig-build-system) (arguments (list #:zig zig-0.13 #:install-source? #f)) (native-inputs (list gtk libadwaita pkg-config zig)) (home-page "https://www.ghossty.org/") (synopsis "Fast, feature-rich, and cross-platform terminal emulator that uses platform-native UI and GPU acceleration.") (description "Ghostty is a terminal emulator that differentiates itself by being fast, feature-rich, and native. While there are many excellent terminal emulators available, they all force you to choose between speed, features, or native UIs. Ghostty provides all three.") (license expat)))) ghostty
--
boogs
T
T
Tobias Geerinckx-Rice wrote on 1 Jan 14:13 +0100
(address . control@debbugs.gnu.org)
BB095A0B-3CF7-4F27-9803-F4B4996B9B2E@tobias.gr
merge 75236 75237
M
M
Murilo wrote on 1 Jan 14:44 +0100
D6QS5AANIVYZ.3E3F2IKG2OJ1B@disroot.org
Hi, sadly its not an easy task as you might be expecting it to be.

It vendors a lot of dependencies in the repository and recursive dependency
replacing with zig fetch isn't quite there yet so we have to do some more work,
create a cache and vendor it with --system. I don't know if this is the best
approach since I never touched anything zig, but it seems to be the easiest from
my research.

Fortunately I've already went through the trouble and packaged it on my channel
a couple days ago so you can use it right away :)

Feel free to take a look at my package definition [0] or use my channel [1]. I
plan to upstream it here once holidays are over and I have some free time, whats
left to do is looking at the vendored sources one by one to ensure everything is
free and there are no nasty pre-built stuff inside the sources, and see if any
of it can be made into a proper guix package so we can use it as normal inputs.
Feel free to help with those too if you want to, the more help the merrier :)

B
(name . Murilo)(address . murilo@disroot.org)(address . 75237@debbugs.gnu.org)
c7f38038-35f1-4837-b9ee-5ea36591ebd6@email.android.com
Attachment: file
F
F
Frank J. Cameron wrote on 10 Jan 00:10 +0100
Re: Packaging ghostty terminal
(address . 75237@debbugs.gnu.org)
472b98bc-76c7-41b6-809b-7bc18b460886@app.fastmail.com
Murilo wrote on 1 Jan 14:44 +0100
Toggle quote (3 lines)
> Fortunately I've already went through the trouble and packaged it on my channel
> a couple days ago so you can use it right away :)

Thanks for the package; I can confirm it built successfully for me as well.

So, I took your code and munged it with the version I had been working on. My
new version doesn't actually work :-) but, I posted it on the off chance that
someone would find it interesting.


I was trying to handle the zig system pkgdir by defining a package for each
module that could simply be added as build-inputs:

(native-inputs (list [...]
zig-pkgdir-breakpad-6dc2a1ea zig-pkgdir-cimgui-1f40c122
zig-pkgdir-fontconfig-a4fcb3b7 zig-pkgdir-freetype-2adf969d
zig-pkgdir-glfw-98a7272d zig-pkgdir-glslang-9dd23ba1
zig-pkgdir-harfbuzz-d1063122 zig-pkgdir-highway-8cbe165b
zig-pkgdir-imgui-8bfc6402 zig-pkgdir-iterm2_themes-f0498620
zig-pkgdir-libpng-723b1c66 zig-pkgdir-libxev-02078bbf
zig-pkgdir-libxml2-65a64f7d zig-pkgdir-mach_glfw-37696a62
zig-pkgdir-oniguruma-cd9706bb zig-pkgdir-sentry-37a9c77e
zig-pkgdir-spirv_cross-2748c8da zig-pkgdir-utfcpp-a931e641
zig-pkgdir-vaxis-c6e4c087 zig-pkgdir-vaxis-c8c91d2f
zig-pkgdir-vulkan_headers-894fa2cf zig-pkgdir-wayland_headers-da2c11ca
zig-pkgdir-wuffs-de700462 zig-pkgdir-x11_headers-57b36465
zig-pkgdir-xcode_frameworks-d67d19cb zig-pkgdir-z2d-06b5416a
zig-pkgdir-zf-b5dd35e8 zig-pkgdir-zg-984c6e40
zig-pkgdir-zigimg-1be35cf5 zig-pkgdir-zig_js-f4f6fefc
zig-pkgdir-ziglyph-6a02cf25 zig-pkgdir-zig_objc-4415c634
zig-pkgdir-zlib-66742efb))

It does look like it populates the pkgdir successfully (with symlinks into the
store) and starts building but fails:

error: sub-compilation of libcxx failed
/gnu/store/...-zig-pkgdir-xcode_frameworks-.../include/i386/_types.h:48:33: note: typedef redefinition with different types ('long long' vs 'long')
[...]
/gnu/store/...-glibc-2.39/include/bits/types.h:44:25: note: previous definition is here
[...]
Build Summary: 78/81 steps succeeded; 1 failed (disable with --summary none)
M
M
Murilo wrote on 10 Jan 14:49 +0100
Re: bug#75237: Packaging ghostty terminal
D6YFW4BTOY56.3I5WTCTLAXAB8@disroot.org
Hi Frank,

Toggle quote (7 lines)
> error: sub-compilation of libcxx failed
> /gnu/store/...-zig-pkgdir-xcode_frameworks-.../include/i386/_types.h:48:33: note: typedef redefinition with different types ('long long' vs 'long')
> [...]
> /gnu/store/...-glibc-2.39/include/bits/types.h:44:25: note: previous definition is here
> [...]
> Build Summary: 78/81 steps succeeded; 1 failed (disable with --summary none)

I took a glance at the package definition in the link you sent, it seems to me
that this error is caused because ghostty vendors [1] various zig custom builds
[2] from the C sources within its own source repository.
What I suspect is happening (again, I didn't try building your
package definition to check, I could be wrong!) with this error is the
'unpack-dependencies phase from zig-build-system runs 'zig fetch' in all the
dependencies and thus replaces all the zig sources in the main 'build.zig.zon',
including the local vendored ones [2], thus you won't get the custom vendored
builds from the local source repository [1].

This is why I replaced [3] the 'unpack-dependencies in the %standard-phases.
This doesn't mean we absolutely cannot use 'unpack-dependencies, infact I am
trying to package it with the 'unpack-dependencies phase, but its proving to be
a bit hard to accomodate it.
The easier option would be to reimplement it and only run 'zig fetch' on the
packages that we want it to replace, but it would be best if we could use the
'unpack-dependency phase from zig-build-system for upstreaming purposes.

M
M
Murilo wrote on 10 Jan 15:27 +0100
Re: Packaging ghostty terminal
(address . 75237@debbugs.gnu.org)
D6YGP1P9526U.2N1ZMQ6CRAJH@disroot.org
I essentially gave up on packaging ghostty for upstreaming, already spent too
much time on this so I'm moving on.
Will continue to update the current working version on my channel, for personal
use.
Here's my WIP guix branch for ghostty if someone wants to give it a shot, in the
hopes that it might be useful for someone:


Some zig dependencies there already meet the upstreaming requirements.

The ghostty package does not build, getting some strange errors because of
libvaxis, and missing some zig-mach dependencies.

Might experience some version mismatches because I'm initially using the C
packages we already have packaged on guix.

It needs wuffs which is going to be pain :-(.

The 'fix-path phase substitute* does not work, can be removed, was something I
was experimenting with.

The 'hard-disable-macos-dependencies is also an experiment, might not work.
F
F
Frank J. Cameron wrote on 10 Jan 16:26 +0100
Re: bug#75237: Packaging ghostty terminal
890d5d71-a351-4746-a0f7-41ab51491fc6@app.fastmail.com
On Fri, Jan 10, 2025, at 1:49 PM, Murilo wrote:
Toggle quote (12 lines)
> I took a glance at the package definition in the link you sent, it seems to me
> that this error is caused because ghostty vendors [1] various zig custom builds
> [2] from the C sources within its own source repository.
> What I suspect is happening (again, I didn't try building your
> package definition to check, I could be wrong!) with this error is the
> 'unpack-dependencies phase from zig-build-system runs 'zig fetch' in all the
> dependencies and thus replaces all the zig sources in the main 'build.zig.zon',
> including the local vendored ones [2], thus you won't get the custom vendored
> builds from the local source repository [1].
>
> This is why I replaced [3] the 'unpack-dependencies in the %standard-phases.

I don't that's the issue in this case. Just now as an experiment, I replaced
unpack-dependencies instead of running after unpack and hit the same error. It
appears to me that since I was defining the module packages with
copy-build-system rather than zig-build-system that was bypassing the zig fetch
magic in unpack-dependencies (there are no zig fetch appearing in the log). As
another experiment, I used zig-build-system instead of copy-build-system for the
module packages and it did do the zig fetch magic in that case (zig fetch was
visible in the log) (and then failed in a different way).

Toggle quote (4 lines)
> This doesn't mean we absolutely cannot use 'unpack-dependencies, infact I am
> trying to package it with the 'unpack-dependencies phase, but its proving to be
> a bit hard to accomodate it.

Yesterday, I started from scratch with each zig module dependency defined as a
package using zig-build-system (modeled after libxkcb in zig-xyz) and letting
the default unpack-dependencies do the zig fetch magic. It got past the point of
trying to download dependencies and then died while building:

starting phase `build'
running: ("zig" "build" "--prefix" "" "--prefix-lib-dir" "lib" "--prefix-exe-dir" "bin" "--prefix-include-dir" "include" "--verbose" "-Dtarget=x86_64-linux-gnu" "-j2" "--release=fast")
thread 1257 panic: unable to find module 'freetype'
/gnu/store/ncxvllgf84qnnylw7b1snwvg2sapfc1g-zig-0.13.0/lib/zig/std/Build.zig:1857:18: 0x1152797 in module (build)
panic("unable to find module '{s}'", .{name});
^
/tmp/guix-build-ghostty-1.0.1.drv-0/source/build.zig:1114:67: 0x1152ce7 in addDeps (build)
step.root_module.addImport("freetype", freetype_dep.module("freetype"));

Thanks!

-frank
F
F
Frank J. Cameron wrote on 10 Jan 20:00 +0100
89e91bfd-92e5-4c5b-ae85-2aeac05587bd@app.fastmail.com
On Fri, Jan 10, 2025, at 3:26 PM, Frank J. Cameron wrote:
Toggle quote (14 lines)
> starting phase `build'
> running: ("zig" "build" "--prefix" "" "--prefix-lib-dir" "lib"
> "--prefix-exe-dir" "bin" "--prefix-include-dir" "include" "--verbose"
> "-Dtarget=x86_64-linux-gnu" "-j2" "--release=fast")
> thread 1257 panic: unable to find module 'freetype'
> /gnu/store/ncxvllgf84qnnylw7b1snwvg2sapfc1g-zig-0.13.0/lib/zig/std/Build.zig:1857:18:
> 0x1152797 in module (build)
> panic("unable to find module '{s}'", .{name});
> ^
> /tmp/guix-build-ghostty-1.0.1.drv-0/source/build.zig:1114:67: 0x1152ce7
> in addDeps (build)
> step.root_module.addImport("freetype",
> freetype_dep.module("freetype"));

I think this is caused by unpack-dependencies; it's overwriting the top-level
dependency "freetype" (build.zig.zon -> pkg/freetype) with low-level dependency
"freetype" (pkg/freetype/build.zig.zon -> upstream source).

I'm not sure if rewriting rewriting the build.zig.zon files is better than
running in system mode with a populated pkgdir.
F
F
Frank J. Cameron wrote on 10 Jan 22:21 +0100
Re: Packaging ghostty terminal
dd53ca89-dfb2-4ecd-88a5-5a87f8da5a1d@app.fastmail.com
On Thu, Jan 9, 2025, at 11:10 PM, Frank J. Cameron wrote:
Toggle quote (10 lines)
> error: sub-compilation of libcxx failed
> /gnu/store/...-zig-pkgdir-xcode_frameworks-.../include/i386/_types.h:48:33:
> note: typedef redefinition with different types ('long long' vs 'long')
> [...]
> /gnu/store/...-glibc-2.39/include/bits/types.h:44:25: note:
> previous definition is here
> [...]
> Build Summary: 78/81 steps succeeded; 1 failed (disable with --summary
> none)


I don't know how I fixed it :-), but it builds now (symlinking pkgdir):

$ guix gc -D /gnu/store/*-zig-*
$ guix gc -D /gnu/store/*-ghostty-*

$ guix build -f terminals.scm
[...]
building /gnu/store/kb6aq3hnhikgibrcvf239z9aiz08w8z7-zig-module-breakpad-12207fd37bb8251919c112dcdd8f616a491857b34a451f7e4486490077206dc2a1ea.drv...
building /gnu/store/32mf5g5d95q246bmjh7mnj81a3rfn40x-zig-module-cimgui-1220061d44ec37e6a240b31061c87cece7026d3dde885125e670f0f2d2811f40c122.drv...
building /gnu/store/mjvq1zg38xbhq105zak9hzp9cpw48fyk-zig-module-fontconfig-12201149afb3326c56c05bb0a577f54f76ac20deece63aa2f5cd6ff31a4fa4fcb3b7.drv...
building /gnu/store/m7fypjbibmmymi9n3fw1y9awa8lcq0n2-zig-module-freetype-1220b81f6ecfb3fd222f76cf9106fecfa6554ab07ec7fdc4124b9bb063ae2adf969d.drv...
building /gnu/store/9x3xfm8rc04h076ddsqbsz492ib1dlkb-zig-module-glfw-1220736fa4ba211162c7a0e46cc8fe04d95921927688bff64ab5da7420d098a7272d.drv...
building /gnu/store/v7dnnzkykc5g2raz3ijcmy8hkgrsz0bq-zig-module-glslang-12201278a1a05c0ce0b6eb6026c65cd3e9247aa041b1c260324bf29cee559dd23ba1.drv...
building /gnu/store/64ww8f226r3q21g2233b12v3c8n88ib3-zig-module-harfbuzz-1220b8588f106c996af10249bfa092c6fb2f35fbacb1505ef477a0b04a7dd1063122.drv...
building /gnu/store/1z1y4dwr0hpcdi0cmlpg1prr67610214-zig-module-highway-12205c83b8311a24b1d5ae6d21640df04f4b0726e314337c043cde1432758cbe165b.drv...
building /gnu/store/qr2rgp8ym0hqrimrsg0icicjvjkml9q6-zig-module-imgui-1220bc6b9daceaf7c8c60f3c3998058045ba0c5c5f48ae255ff97776d9cd8bfc6402.drv...
building /gnu/store/xw96qj8q1b23199r21n4bym05pxavdjx-zig-module-iterm2_themes-1220cc25b537556a42b0948437c791214c229efb78b551c80b1e9b18d70bf0498620.drv...
building /gnu/store/5gd742ac6ji7q5rdq2n1a43igv25azy9-zig-module-libpng-1220aa013f0c83da3fb64ea6d327f9173fa008d10e28bc9349eac3463457723b1c66.drv...
building /gnu/store/l4224lcjq0yqmh9zjd6dssqw54207bdw-zig-module-libxev-12206029de146b685739f69b10a6f08baee86b3d0a5f9a659fa2b2b66c9602078bbf.drv...
building /gnu/store/rm2n69yad36fll389gidpr5png3hfcah-zig-module-libxml2-122032442d95c3b428ae8e526017fad881e7dc78eab4d558e9a58a80bfbd65a64f7d.drv...
building /gnu/store/cm68p0hd30i9a4yggs1in55sqxkbihsi-zig-module-mach_glfw-12206ed982e709e565d536ce930701a8c07edfd2cfdce428683f3f2a601d37696a62.drv...
building /gnu/store/dk8nhr2ycvzjycj2kd6bwf6z4ikzy13i-zig-module-oniguruma-1220c15e72eadd0d9085a8af134904d9a0f5dfcbed5f606ad60edc60ebeccd9706bb.drv...
building /gnu/store/h4md05dxzkpqhxdyly861pcqg3dhsynf-zig-module-sentry-1220446be831adcca918167647c06c7b825849fa3fba5f22da394667974537a9c77e.drv...
building /gnu/store/aaf8hy5l2lbm3f05479n7nacsr6gp3qm-zig-module-spirv_cross-1220fb3b5586e8be67bc3feb34cbe749cf42a60d628d2953632c2f8141302748c8da.drv...
building /gnu/store/ffqcnf91zn2vzvl86yzkm8xn2kjm31z4-zig-module-utfcpp-1220d4d18426ca72fc2b7e56ce47273149815501d0d2395c2a98c726b31ba931e641.drv...
building /gnu/store/64fibns1g2nvl4scfnzmljb5hlkqz3vl-zig-module-vaxis-12200df4ebeaed45de26cb2c9f3b6f3746d8013b604e035dae658f86f586c8c91d2f.drv...
building /gnu/store/1hd71i4cby3dblvkvik2k9pyqn0zv6wv-zig-module-vaxis-1220c72c1697dd9008461ead702997a15d8a1c5810247f02e7983b9f74c6c6e4c087.drv...
building /gnu/store/vc0zdnvgcy3axqclrwdcxr8rzz4b1h0f-zig-module-vulkan_headers-122004bfd4c519dadfb8e6281a42fc34fd1aa15aea654ea8a492839046f9894fa2cf.drv...
building /gnu/store/7jdzd10apa2lf9dh2478kgfqqi8hcjjz-zig-module-wayland_headers-1220b3164434d2ec9db146a40bf3a30f490590d68fa8529776a3138074f0da2c11ca.drv...
building /gnu/store/hva6qdwcfs30yrcx9zibcjssmpmjabm3-zig-module-wuffs-12200984439edc817fbcbbaff564020e5104a0d04a2d0f53080700827052de700462.drv...
building /gnu/store/3sflpq9pa5vhs8ksz9b36x6sn9751h2i-zig-module-x11_headers-122089c326186c84aa2fd034b16abc38f3ebf4862d9ae106dc1847ac44f557b36465.drv...
building /gnu/store/dqdl8pd6b25a4xzjc56m98kkz57lh32w-zig-module-xcode_frameworks-12202adbfecdad671d585c9a5bfcbd5cdf821726779430047742ce1bf94ad67d19cb.drv...
building /gnu/store/larg3sa3c8i7fymzbkzyvp191z4qx9d2-zig-module-z2d-12201f0d542e7541cf492a001d4d0d0155c92f58212fbcb0d224e95edeba06b5416a.drv...
building /gnu/store/l7h110phpki3h4a30c62271g3nr8i70w-zig-module-zf-1220edc3b8d8bedbb50555947987e5e8e2f93871ca3c8e8d4cc8f1377c15b5dd35e8.drv...
building /gnu/store/k6dvnlb4iwb3dd31h26i1jl2jfx9fikj-zig-module-zg-122055beff332830a391e9895c044d33b15ea21063779557024b46169fb1984c6e40.drv...
building /gnu/store/xv0s9i2m4jjpqv61c0x4ad98lf687l4n-zig-module-zig_js-12205a66d423259567764fa0fc60c82be35365c21aeb76c5a7dc99698401f4f6fefc.drv...
building /gnu/store/4lrdv1pnxa2clpdxw78yvi81mwimf5ip-zig-module-zig_objc-1220e17e64ef0ef561b3e4b9f3a96a2494285f2ec31c097721bf8c8677ec4415c634.drv...
building /gnu/store/1drfr6mf2lkxajj4yybryz1p10a0iv95-zig-module-zigimg-1220dd654ef941fc76fd96f9ec6adadf83f69b9887a0d3f4ee5ac0a1a3e11be35cf5.drv...
building /gnu/store/pycym7v0mv9s7cr454k86zgg3wrc083q-zig-module-ziglyph-12207831bce7d4abce57b5a98e8f3635811cfefd160bca022eb91fe905d36a02cf25.drv...
building /gnu/store/p0cr752q6yjdy59cxp3djfjg6ab31kgg-zig-module-zlib-1220fed0c74e1019b3ee29edae2051788b080cd96e90d56836eea857b0b966742efb.drv...
building /gnu/store/930mxl409i3w33r77fj2g6pbjicph676-ghostty-1.0.1.drv...
The following derivation will be built:
/gnu/store/q8dr343h6m84ha29dapsc081yavq5xnc-profile.drv
[...]

$ which ghostty
/home/user/.guix-profile/bin/ghostty
$ realpath $(which ghostty)
/gnu/store/a6gjp1168zl3vh5hgyln0m136b96i69v-ghostty-1.0.1/bin/ghostty
F
F
Frank J. Cameron wrote on 31 Jan 05:03 +0100
(address . 75237@debbugs.gnu.org)
112f1219-2a45-4884-80c7-a3276e57829e@app.fastmail.com
Quick and dirty update for ghostty 1.1.0:

$ /gnu/store/3vk4qi1mvgmmi6mwzli1lix7klrkdigk-ghostty-1.1.0/bin/ghostty +version
Ghostty 1.1.0-dev+0000000

Version
- version: 1.1.0-dev+0000000
- channel: tip
Build Config
- Zig version: 0.13.0
- build mode : builtin.OptimizeMode.ReleaseFast
- app runtime: apprt.Runtime.gtk
- font engine: font.main.Backend.fontconfig_freetype
- renderer : renderer.OpenGL
- libxev : main.Backend.io_uring
- desktop env: other
- GTK version:
build : 4.14.5
runtime : 4.14.5
- libadwaita : enabled
build : 1.5.2
runtime : 1.5.2
- libX11 : enabled
- libwayland : enabled
F
F
Frank J. Cameron wrote on 2 Feb 05:13 +0100
(address . 75237@debbugs.gnu.org)
2f882ada-3626-4b3c-be5a-19510bbec39c@app.fastmail.com
On Fri, Jan 31, 2025, at 4:03 AM, Frank J. Cameron wrote:
Toggle quote (3 lines)
> Quick and dirty update for ghostty 1.1.0:
> https://gitlab.com/-/snippets/4792310

Reworked into zig-xyz.scm:


$ guix repl -L .
scheme@(guix-user)> ,module (gnu packages zig-xyz)
scheme@(gnu packages zig-xyz)> ,build ghostty
$69 = "/gnu/store/clxk8f8bbhmmj9xqn9pq84sdy61z44av-ghostty-1.1.0"

$ /gnu/store/clxk8f8bbhmmj9xqn9pq84sdy61z44av-ghostty-1.1.0/bin/ghostty +version
Ghostty 1.1.0-dev+0000000

Version
- version: 1.1.0-dev+0000000
- channel: tip
Build Config
- Zig version: 0.13.0
- build mode : builtin.OptimizeMode.ReleaseFast
- app runtime: apprt.Runtime.gtk
- font engine: font.main.Backend.fontconfig_freetype
- renderer : renderer.OpenGL
- libxev : main.Backend.io_uring
- desktop env: other
- GTK version:
build : 4.14.5
runtime : 4.14.5
- libadwaita : enabled
build : 1.5.2
runtime : 1.5.2
- libX11 : enabled
- libwayland : enabled
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 75237@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 75237
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch