# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie # SPDX-License-Identifier: MIT { lib, stdenv, callPackage, zig_0_17, }: let # Generated from build.zig.zon by zon2nix; regenerate with # nix develop -c zon2nix --17 --nix=build.zig.zon.nix build.zig.zon zigDeps = callPackage ./build.zig.zon.nix { }; in stdenv.mkDerivation (finalAttrs: { pname = "zig-geo"; version = "0.2.0"; # Named rather than filtered, so that editing something outside this list # -- the flake, the workflow, a scratch file -- does not rebuild the package. src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./build.zig ./build.zig.zon ./build.zig.zon.nix ./src ./tests ./tools ./LICENSES ./REUSE.toml ]; }; nativeBuildInputs = [ zig_0_17.hook ]; # A Nix build has no network and the Zig package manager wants one, so the # dependencies are realised by Nix and handed over as a directory. `--system` # does not merely offer it, 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 that fails somewhere less legible. 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 computation, so they run here as well as in CI. doCheck = true; # A library: `zig build` installs nothing, and a derivation with no output # is an error, so the documentation is what gets installed. postInstall = '' zig build docs --prefix $out --system ${zigDeps} ''; meta = { description = "Positions on the Earth for Zig: point-in-polygon, bounding boxes, great-circle distance and bearing"; homepage = "https://git.jcollie.dev/jeff/zig-geo"; license = lib.licenses.mit; platforms = lib.platforms.unix; }; })