Subject: Re: bug#75237: Packaging ghostty terminal

From: "Frank J. Cameron" <[email-masked]>
Date: Fri, 10 Jan 2025 15:26:17 +0000

On Fri, Jan 10, 2025, at 1:49 PM, Murilo wrote:
> 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).

> 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