Something went wrong. Try again.
The WebSocket Protocol (RFC 6455) for Zig: framing, a client, and a server handshake on zig-http
Something went wrong. Try again.
zig-websocket build.zig.zon.nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146# generated by zon2nix (https://github.com/jcollie/zon2nix){ lib, fetchgit, fetchurl, fetchzip, runCommandLocal, zig_0_17, zstd, name ? "zig-packages", # Accepted and ignored. Expressions from zon2nix before 0.8 built the # packages with `linkFarm`, and some callers override it with a version that # copies, to work around Zig mishandling symlinked package directories # (https://codeberg.org/ziglang/zig/issues/32121). The packages are real # directories now, so the override is not needed, and is taken here only so # that passing it is not an error. linkFarm ? null,}:let # A git repository, checked out the way Zig reads it: every file as # committed. An ordinary checkout applies the repository's `.gitattributes`, # which can rewrite a file's line endings or run it through a filter, and # the package would then no longer match its hash. Pointing git at its # built-in empty tree for attributes turns them all off, and `core.autocrlf` # is turned off too, since it converts line endings even without them. # zon2nix computes the hash with exactly these settings. fetchZigGit = args: fetchgit ( args // { fetchSubmodules = false; preFetch = '' export GIT_ATTR_SOURCE=4b825dc642cb6eb9a060e54bf8d69288fbee4904 export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.autocrlf GIT_CONFIG_VALUE_0=false ''; } );
# Every package, by the hash Zig knows it by, as Nix fetches it. packages = { "http-0.3.0-e28mQOCUGQCecLGseNqEH9AOYhwI5gkKMe44gwcF6OLL" = fetchZigGit { name = "http"; url = "https://git.jcollie.dev/jeff/zig-http.git"; rev = "5ff99a8bd2f4d229f23cc447357dd0232b19f107"; hash = "sha256-r1b/MYQqz4vk9Ts8lfsN+9AQqwsf7c1wdfb4/4DdAME="; }; "zig_quic-0.2.1-4oF4nh4TGwChRHAERCyHrwF2pH6V4iuzwOc3LFG4grhQ" = fetchZigGit { name = "quic"; url = "https://git.jcollie.dev/jeff/zig-quic.git"; rev = "5bed6d4aa2dae529f1f00a1dae3074b13497cc31"; hash = "sha256-tFLDX/gmxfRnYG/mp9VmNRL+Q7ECHng0leX9xEsXDKo="; }; "tls-0.1.0-ER2e0gB8CQA1POILS85Nvchyyd7qS4V7OEQ-nDYvQv-K" = fetchZigGit { name = "tls"; url = "https://git.jcollie.dev/jeff/tls.zig.git"; rev = "e689dc9d9fd36a6a53b121f87073c72dcba4903d"; hash = "sha256-SOmgC1kVU7uHESMR08A/eJeaiiBYcVFQDnijVI9EXbY="; }; "uri-0.4.0-yCrwNG9RFABqcGa05zp-QRUjfajbARn7a9KoY6N6A1v_" = fetchZigGit { name = "uri"; url = "https://git.jcollie.dev/jeff/zig-uri.git"; rev = "0c174b5afc0b8c1793f4b02de58d25f4b768f102"; hash = "sha256-YFO1GCcoJB/QLi14FD7+6jNET4SX06etOt6ZwrMcDnY="; }; "uucode-0.2.0-ZZjBPm6FVgBcY-79AHV8ckQj86z0JwOyVyj89VeZrEiv" = fetchZigGit { name = "uucode"; url = "https://github.com/jacobsandlund/uucode"; rev = "1fb73433bba5d93366c57f23ff2e9d7939746500"; hash = "sha256-fZTYVFN0N10R0Ty+3tpMkTLqEBq4tTpkBK6G1m6VgmY="; }; "z46-0.2.0-_AxhwAXTCQDzvmmh5CP6zrvAk03GpkQz_fdYpbc53DND" = fetchZigGit { name = "z46"; url = "https://git.jcollie.dev/jeff/z46.git"; rev = "cde52f655fa3a099c016c042c080f8112330f682"; hash = "sha256-RPKBTbLZ7bIJXb7g5CBytRXGPkT8Tn8dhiavVpz27Tw="; }; };
# The packages whose own manifest declares a dependency by `.path`, which # Zig 0.16.0 cannot build through `zig build --system`. Listed here too so # that every version's expression offers the same things; see the README. pathDependencyPackages = [ ];in# One directory holding every package the way Zig unpacks it -- filtered by# its manifest's `.paths` and checked against its hash -- which is what# `zig build --system` wants.## They have to be real directories holding real files, not links into each# package's own store path. Zig runs a dependency's build steps from inside# it and counts its way back out through `..`, which lands in the wrong place# when the directory is a symlink; and `installHeadersDirectory` copies only# what the directory walk calls a file, so symlinked headers are skipped# without a word. Building them all in one derivation gives real files from# the start, without a second copy of everything.runCommandLocal name { nativeBuildInputs = [ zig_0_17 ]; passthru = { inherit pathDependencyPackages; }; } '' mkdir "$out"
# Zig 0.17 runs `zig fetch` in a build runner it compiles into the global # cache the first time, which takes a minute or more. Every package shares # one cache, then, and it is compiled once here before they are fetched # several at a time, rather than by each of them at once. export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/cache" mkdir -p "$ZIG_GLOBAL_CACHE_DIR" zig fetch --help >/dev/null
# Without `--save`, which wants a project to save into, Zig 0.17 unpacks # nothing where it can be found: what it keeps is `p/<hash>.tar.gz` in # the global cache, the package filtered by its manifest's `.paths` under # a single directory named by its hash. Unpacking that gives the # directory `zig build --system` wants. unpack() { local work="$TMPDIR/work/$1" mkdir -p "$work"
local hash if ! hash="$(cd "$work" && zig fetch "$2" 2>"$work/log")"; then cat "$work/log" >&2 return 1 fi if [ "$hash" != "$1" ]; then echo "$2 is $hash to Zig, not $1" >&2 return 1 fi tar -xzf "$ZIG_GLOBAL_CACHE_DIR/p/$1.tar.gz" -C "$out" rm -f "$ZIG_GLOBAL_CACHE_DIR/p/$1.tar.gz" rm -rf "$work" } export -f unpack
# Several at a time: `zig fetch` spends most of a package on one core. # `-r` because otherwise xargs runs `unpack` once, with no arguments, when # there are no packages at all, and the build fails. cores="''${NIX_BUILD_CORES:-0}" if [ "$cores" -le 0 ]; then cores="$(nproc)"; fi xargs -r -P "$cores" -n 2 bash -c 'unpack "$@"' unpack <<'EOF' ${lib.concatStrings (lib.mapAttrsToList (hash: src: "${hash} ${src}\n") packages)} EOF ''