Skip to content
Draft
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ transport; its revision and unpacked source hash are pinned in
also verifies the native compatibility contract and runtime closure, runs
the package tests, and checks installed completions. `nix develop` supplies
the Rust toolchain and the same native artifact, without Zig.
GitHub-hosted Zig dependency archives use fixed-output downloads with the original
URL followed by an equivalent `codeload.github.com` fallback. URLs and archive
checksums come from Ghostty's pinned package manifest; the Zig package-cache
output hash is unchanged. This improves cold-cache build reliability without
changing runtime behavior or dependency contents.

With Cargo (see the build requirements below):

Expand Down
27 changes: 27 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,29 @@
hash = ghosttyContract.sourceHash;
};

# Keep transport mirrors separate from Zig's package content pins.
# Upstream's manifest supplies both archive byte hashes and cache names.
ghosttyGithubArchives = map
(package:
let
archiveUrl = builtins.match
"https://github.com/([^/]+/[^/]+)/archive/(.+)\\.tar\\.gz"
package.url;
in package // {
archive = pkgs.fetchurl {
urls = [
package.url
"https://codeload.github.com/${builtins.elemAt archiveUrl 0}/tar.gz/${builtins.elemAt archiveUrl 1}"
];
sha256 = package.sha256;
};
})
(builtins.filter
(package: package.type == "archive" && builtins.match
"https://github.com/([^/]+/[^/]+)/archive/(.+)\\.tar\\.gz"
package.url != null)
(builtins.fromJSON (builtins.readFile "${ghosttySrc}/flatpak/zig-packages.json")));

# Ghostty's zig package cache, in the layout `zig build --system <dir>`
# reads (one directory per package, named by its content hash). Fetched
# with Ghostty's own script because `zig build --fetch` skips transitive
Expand All @@ -79,6 +102,10 @@
buildPhase = ''
runHook preBuild
export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-global-cache"
${lib.concatMapStringsSep "\n" (package: ''
substituteInPlace build.zig.zon.txt \
--replace-fail ${lib.escapeShellArg package.url} ${lib.escapeShellArg (toString package.archive)}
'') ghosttyGithubArchives}
./nix/build-support/fetch-zig-cache.sh
runHook postBuild
'';
Expand Down
Loading