# 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 # # A Nix build has no network and the Zig package manager wants one, so the # dependencies are fetched by Nix into a link farm named by Zig package # hash -- the layout of `p/` in Zig's global cache -- and handed over with # `--system`. zigDeps = callPackage ./build.zig.zon.nix { }; in stdenv.mkDerivation (finalAttrs: { pname = "zig-gmail"; version = "0.1.0"; # Named rather than filtered, so that editing something outside this list -- # the flake, the README, a scratch file -- does not rebuild the package. src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./build.zig ./build.zig.zon ./src ./tests ./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 the network. 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: the ones that would need a network talk to a Gmail # written a hundred lines away, on a loopback socket the build sandbox has. doCheck = true; meta = { description = "A Gmail API client library for Zig"; homepage = "https://git.jcollie.dev/jeff/zig-gmail"; license = lib.licenses.mit; platforms = lib.platforms.unix; }; })