# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie # SPDX-License-Identifier: MIT { description = "zig-quic"; inputs = { nixpkgs = { url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; }; # Zig 0.17, which nixpkgs does not have yet. The overlay packages each # release; `zigFor` below names the one this project builds with. zig = { url = "git+https://git.jcollie.dev/jeff/zig-overlay.git"; inputs = { nixpkgs.follows = "nixpkgs"; zon2nix.follows = "zon2nix"; }; }; # Not the `zon2nix` in nixpkgs, which is a different program by a # different author and takes different options. zon2nix = { url = "github:jcollie/zon2nix"; inputs = { nixpkgs.follows = "nixpkgs"; zig.follows = "zig"; }; }; }; outputs = { nixpkgs, zig, zon2nix, ... }: let inherit (nixpkgs) lib; makePackages = system: import nixpkgs { inherit system; }; forAllSystems = lib.genAttrs lib.systems.flakeExposed; # The virtual machine tests are NixOS ones, so they exist only where # NixOS does. Without this `nix flake check` tries to evaluate them for # Darwin and fails before it has run anything. forLinuxSystems = lib.genAttrs ( lib.filter (system: lib.hasSuffix "-linux" system) lib.systems.flakeExposed ); zigFor = system: zig.packages.${system}."0.17.0"; in { packages = forAllSystems ( system: let pkgs = makePackages system; in rec { zig-quic = pkgs.callPackage ./package.nix { zig = zigFor system; }; default = zig-quic; # The dependency farm on its own, for a job that runs `zig build` # without building the package to get at it. zig-deps = pkgs.callPackage ./build.zig.zon.nix { zig_0_17 = zigFor system; }; } ); # Linux only: without this `nix flake check` tries to evaluate a NixOS # test for Darwin and fails before running anything. checks = lib.genAttrs (lib.filter (system: lib.hasSuffix "-linux" system) lib.systems.flakeExposed) ( system: let pkgs = makePackages system; zig-quic = pkgs.callPackage ./package.nix { zig = zigFor system; }; in { inherit zig-quic; # Against aioquic, over a real socket. Everything in `zig build # test` is this library talking to itself. interop = pkgs.testers.runNixOSTest (import ./tests/nixos/interop.nix { inherit zig-quic; }); # RFC 7250 raw public keys against OpenSSL's QUIC client, which # shares neither the TLS nor the QUIC with this library. openssl = pkgs.testers.runNixOSTest (import ./tests/nixos/openssl.nix { inherit zig-quic; }); # draft-ietf-quic-multipath-21 between two machines: a second # path from a second socket, opened, validated and used. multipath = pkgs.testers.runNixOSTest (import ./tests/nixos/multipath.nix { inherit zig-quic; }); # Raw public keys against iroh itself, which is what they were # built to reach. iroh = pkgs.testers.runNixOSTest ( import ./tests/nixos/iroh.nix { inherit zig-quic; iroh-doq = pkgs.callPackage ./tests/iroh/package.nix { }; } ); } ); devShells = forAllSystems ( system: let pkgs = makePackages system; in { default = pkgs.mkShell { name = "zig-quic"; nativeBuildInputs = [ (zigFor system) pkgs.git-pages-cli pkgs.reuse # The other implementations to test against. curl is the # strictest reading of RFC 9112 likely to connect to this; # h2spec is the conformance suite for RFC 9113, and nghttp2 # brings `h2load` and the `nghttp` debug client. # Regenerates `build.zig.zon.nix`, which is how the Nix build # gets the TLS dependency without a network. Wrapped so that # the `zig env` it shells out to is the one this project builds # with rather than whatever is on the caller's PATH. (pkgs.symlinkJoin { name = "zon2nix"; paths = [ zon2nix.packages.${pkgs.stdenv.hostPlatform.system}.zon2nix ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' wrapProgram $out/bin/zon2nix \ --prefix PATH : ${lib.makeBinPath [ (zigFor system) ]} ''; }) # For reading the specifications and checking vectors by # hand while the implementation catches up with them. pkgs.python3 ]; }; } ); }; }