Something went wrong. Try again.
Positions on the Earth for Zig: point-in-polygon, bounding boxes, and great-circle distance and bearing.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT
{ description = "zig-geo";
inputs = { nixpkgs = { url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; }; # Reads `build.zig.zon`, follows every transitive dependency, and writes a # Nix expression for the lot. A Nix build has no network and the Zig # package manager wants one; this is the bridge. Not the `zon2nix` in # nixpkgs, which is a different program taking different options. zon2nix = { url = "github:jcollie/zon2nix"; inputs.nixpkgs.follows = "nixpkgs"; }; };
outputs = { nixpkgs, zon2nix, ... }: let inherit (nixpkgs) lib; makePackages = system: import nixpkgs { inherit system; }; forAllSystems = lib.genAttrs lib.systems.flakeExposed; in { packages = forAllSystems ( system: let pkgs = makePackages system; in rec { zig-geo = pkgs.callPackage ./package.nix { }; default = zig-geo; # The dependency farm on its own, for a job that runs `zig build` # for something other than the package -- the documentation, say -- # and needs the same dependencies without building the package to # get at them. zig-deps = pkgs.callPackage ./build.zig.zon.nix { }; } );
devShells = forAllSystems ( system: let pkgs = makePackages system; in { default = pkgs.mkShell { name = "zig-geo"; # PROJ's copy of the EPSG dataset, which tools/epsg_ellipsoids.py # reads to write src/epsg_ellipsoids.zig. PROJ_DB = "${pkgs.proj}/share/proj/proj.db"; nativeBuildInputs = [ pkgs.zig_0_17 pkgs.git-pages-cli pkgs.proj pkgs.python3 pkgs.reuse
# Wrapped so that the Zig it shells out to for `zig env` is this # project's rather than whatever happens to be on the caller's # PATH -- without one it prints "unable to execute zig" and # stops, having written nothing, which leaves the previous # generated file in place looking untouched. (pkgs.symlinkJoin { name = "zon2nix"; paths = [ zon2nix.packages.${pkgs.stdenv.hostPlatform.system}.zon2nix ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' wrapProgram $out/bin/zon2nix \ --prefix PATH : ${lib.makeBinPath [ pkgs.zig_0_17 ]} ''; }) ]; }; } ); };}