Something went wrong. Try again.
Reading and writing git repositories in Zig, without running git.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT
{ description = "zig-git: reading and writing git repositories in Zig, without running git";
inputs = { nixpkgs = { url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; }; # Turns build.zig.zon into a Nix expression fetching the Zig # dependencies, since a Nix build has no network. 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-git = pkgs.callPackage ./package.nix { }; default = zig-git; # The Zig dependencies on their own, for a `zig build` run outside # the package. Regenerate after changing build.zig.zon with # nix develop -c zon2nix --17 --nix=build.zig.zon.nix build.zig.zon zig-deps = pkgs.callPackage ./build.zig.zon.nix { }; } );
devShells = forAllSystems ( system: let pkgs = makePackages system; in { default = pkgs.mkShell { name = "zig-git"; # The time zones git and the library both read local time with, # so that the tests comparing dates find the same ones. TZDIR = "${pkgs.tzdata}/share/zoneinfo"; nativeBuildInputs = [ pkgs.zig_0_17 # The oracle: the tests make their repositories with it and # compare answers with it, so its version is pinned here with # everything else rather than taken from the machine. pkgs.git pkgs.git-pages-cli pkgs.reuse # Wrapped so that the Zig it asks is this one. (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 ]} ''; }) ] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.kcov pkgs.perf ]; }; } ); };}