Something went wrong. Try again.
Zig bindings for all 506 operations of the Forgejo API, generated from its own description, and zfj, a command line built on them.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT
{ lib, stdenvNoCC, callPackage, zig_0_17, # A Zig target triple to cross-build for, such as `x86_64-windows`; null # builds for the machine doing the building, and runs the tests. target ? null,}: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 { };instdenvNoCC.mkDerivation (finalAttrs: { pname = if target == null then "zfj" else "zfj-${target}"; # build.zig.zon's, so that the package, `zfj --version` and a release's # archives cannot say different things. version = builtins.head (builtins.match ".*[.]version = \"([^\"]*)\".*" (builtins.readFile ./build.zig.zon));
src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./api ./build.zig ./build.zig.zon ./src ]; };
nativeBuildInputs = [ zig_0_17 ];
# openapi2zig vendors zig-yaml as a `.path` dependency, and `zig build # --system` cannot build a fetched package that has one: Zig 0.17 roots the # package at the absolute store path and then refuses the path dependency # inside it as absolute. Forking such packages from a copy inside the build # root, named by a relative path, gets past that; zon2nix lists which ones # they are. postPatch = lib.concatMapStrings (p: '' cp -rsL --no-preserve=mode ${zigDeps}/${p} fork-${p} '') zigDeps.pathDependencyPackages;
zigBuildFlags = [ "--system" "${zigDeps}" ] ++ map (p: "--fork=fork-${p}") zigDeps.pathDependencyPackages # A cross-built binary is for handing out, and is stripped, since nothing # here could strip it afterwards. ++ lib.optionals (target != null) [ "-Dtarget=${target}" "-Dstrip=true" ]; # 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;
# Each shell's completion script, where that shell looks for one. They # are files rather than `zfj completion`'s output, so that a cross build, # which cannot run what it builds, installs them too. postInstall = '' install -Dm644 src/cli/completions/zfj.fish $out/share/fish/vendor_completions.d/zfj.fish install -Dm644 src/cli/completions/zfj.bash $out/share/bash-completion/completions/zfj install -Dm644 src/cli/completions/_zfj $out/share/zsh/site-functions/_zfj '';
# A cross-built binary cannot be run here to test it, nor stripped or # patched by tools that only know the build machine's format. doCheck = target == null; dontFixup = target != null;
passthru = { inherit target; };
meta = { description = "Zig bindings for the Forgejo API, and a command-line tool built on them"; homepage = "https://git.jcollie.dev/jeff/zfj"; license = lib.licenses.mit; mainProgram = "zfj"; };})