# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie # SPDX-License-Identifier: MIT { lib, stdenv, callPackage, zig_0_16, }: let # Generated from build.zig.zon by zon2nix; regenerate with # nix develop -c zon2nix --16 --nix=build.zig.zon.nix build.zig.zon zigDeps = callPackage ./build.zig.zon.nix { }; in stdenv.mkDerivation (finalAttrs: { pname = "zig-websocket"; version = "0.1.0"; # Named rather than filtered, so that editing something outside this list -- # the flake, a scratch file, the NixOS test that consumes the result -- does # not rebuild the package and, in the test, the whole virtual machine. src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./build.zig ./build.zig.zon ./src (lib.fileset.difference ./tests ./tests/nixos) ./tools ./LICENSES ./README.md ./REUSE.toml ]; }; nativeBuildInputs = [ zig_0_16.hook ]; # `--system` does not merely offer the directory, it forbids fetching # outright: a dependency missing from it is a build error naming the # package rather than a silent attempt to reach a network the sandbox does # not have. zigBuildFlags = [ "--system" "${zigDeps}" ]; # The check phase assembles its own flags rather than reusing the build's, # so without this `zig build test` runs without --system, tries to fetch, # and fails in the sandbox. zigCheckFlags = finalAttrs.zigBuildFlags; # The tests are pure: a scripted conversation in, octets out, no socket. doCheck = true; meta = { description = "The WebSocket Protocol (RFC 6455) for Zig, on top of zig-http"; homepage = "https://git.jcollie.dev/jeff/zig-websocket"; license = lib.licenses.mit; mainProgram = "zig-websocket"; platforms = lib.platforms.unix; }; })