zig-recipe
zig-recipe helps package maintainers turn Zig projects into distribution packages.
When you package a Zig project for an offline build environment, you usually need the same set of facts regardless of the distribution:
- every transitive dependency URL and package hash,
- which dependencies are actually used in your build configuration,
- which system libraries and build-time tools are needed,
- which build options (
-D) and system integrations (-fsys) are available.
zig-recipe collects all of this automatically. You can look at the result right
in your terminal as a summary table, or export it as JSON if you want to feed it
into your own scripts.
It can also generate a ready-to-edit package recipe. Gentoo ebuilds are supported out of the box, and if you package for another distribution or prefer a different layout, you can render the same data through your own Jinja2 template.
Requirements
- Zig 0.17+
- Python 3.12+
If you are packaging an older Zig 0.14–0.16 project, see the legacy zig-ebuilder.
Running with uv
The easiest way to run zig-recipe without installing it globally is with
uv:
$ uvx zig-recipe gentoo ./river
To install it as a persistent CLI tool:
$ uv tool install zig-recipe
Usage
All commands accept an optional path to a Zig project directory (or build.zig).
If you omit the path, zig-recipe uses the current directory.
If a project's dependencies or system libraries depend on non-default build
options, you can forward them to zig build after --:
$ zig-recipe inspect ./project -- -Dbackend=wayland
Inspecting a project
To see what a project needs without writing a recipe file, run inspect:
$ zig-recipe inspect ./project
This prints a summary of packages, build options, system libraries, system integrations, and top-level build steps.
Gentoo ebuilds
To generate a Gentoo ebuild for the project:
$ zig-recipe gentoo ./project
By default, this writes <name>-<version>.ebuild in the current directory
(pass -o - to print to stdout).
Alongside ZBS_DEPENDENCIES and src_configure(), zig-recipe adds comments
listing detected system libraries, build options, and external tools to help
you finish the ebuild by hand. You can control how detailed those comments are
with --comments:
full(default) — descriptions for every build option, system library, and build tool.compact— one-line hints for options and libraries.none— no helper comments at all.
Many Zig projects also declare lazy dependencies that your build never uses
(for example, packages for other operating systems or vendored libraries). You
can choose how those appear in ZBS_DEPENDENCIES with --unused-deps:
comment(default withfullandcompact) — commented out so Portage does not download them.drop(default with--comments none) — omitted fromZBS_DEPENDENCIES.keep— kept uncommented inZBS_DEPENDENCIES.
When updating an existing ebuild to a new release, you often only need the new
dependency list. Passing --deps-only prints just the ZBS_DEPENDENCIES array
to stdout:
$ zig-recipe gentoo ./ghostty --deps-only
See docs/gentoo.md for multi-pass IUSE/src_configure()
mapping and a full walkthrough.
Custom templates
If you are targeting another distribution or want your own file layout, pass a
Jinja2 template to render:
$ zig-recipe render ./my-template.j2 ./project -o recipe.out
Your template can use all of the collected project, dependency, and build information. See docs/templates.md for a walkthrough and example.
Configuration and multi-pass analysis
By default, zig-recipe traces both the default build step and the test step
(when present) to separate test-only dependencies and libraries automatically.
To analyze optional features across multiple build configurations (see
docs/multi-pass.md) or store reusable project metadata
and renderer settings, pass a project config with
--config:
$ zig-recipe gentoo ./river --config river.toml
Machine paths and personal defaults (such as --zig, --cache-dir, or your
preferred Gentoo comment style) can live in a user config
at ~/.config/zig-recipe/config.toml on Linux.
Example
Running zig-recipe gentoo ./river --comments compact -o - on river 0.5.2:
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# Generated by zig-recipe 0.1.0
EAPI=8
declare -g -r -A ZBS_DEPENDENCIES=(
[pixman-0.3.0-LClMnz2VAAAs7QSCGwLimV5VUYx0JFnX5xWU6HwtMuDX.tar.gz]='https://codeberg.org/ifreund/zig-pixman/archive/v0.3.0.tar.gz'
[wayland-0.7.0-lQa1kuP8AQD5dW7_o-VKLVD_QbqXe7Zob78r2su7Pyex.tar.gz]='https://codeberg.org/ifreund/zig-wayland/archive/v0.7.0.tar.gz'
[wlroots-0.20.3-jmOlcsh0BACce9rpfvzUI4V3AalGg9GE0QQkvRFoHo1c.tar.gz]='https://codeberg.org/ifreund/zig-wlroots/archive/v0.20.3.tar.gz'
[xkbcommon-0.5.0-VDqIe8y3AgDU-cGL02xZplwABH3WbpTimrrgbgTgD_3g.tar.gz]='https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.5.0.tar.gz'
# Not used in any analyzed pass:
# [pixman-0.4.0-LClMn_eWAAAa2zACATDpPwjuI5fWlO5cBp_F_M33hnNZ.tar.gz]='https://codeberg.org/ifreund/zig-pixman/archive/v0.4.0.tar.gz'
)
# C/C++ sources detected; verify if LLVM backend is required
ZIG_NEEDS_LLVM=1
ZIG_SLOT="0.17"
inherit zig
DESCRIPTION="TODO"
HOMEPAGE="TODO"
SRC_URI="
# TODO: add project source URL
${ZBS_DEPENDENCIES_SRC_URI}
"
LICENSE="TODO"
SLOT="0"
KEYWORDS="~amd64"
# Detected system libraries: libevdev, libinput, pixman-1, wayland-server, wlroots-0.20, xkbcommon
src_configure() {
local my_zbs_args=(
# -Dstrip=[bool]
# -Dpie=[bool]
# -Dllvm=[bool]
# -Dman-pages=[bool]
# -Dxwayland=[bool]
# -Dversion-string=[string]
)
zig_src_configure
}
Further reading
- How
zig-recipeWorks - Multi-Pass Analysis
- Project Configuration
- User Configuration
- Gentoo Ebuilds
- Custom Jinja2 Templates
License
zig-recipe is licensed under the Apache License 2.0.
Generated recipe files are not covered by this license — you may license them
however you want.
Metadata
Release files for zig-recipe 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zig_recipe-0.2.0.tar.gz | 94.8 kB | With provenance | Details for zig_recipe-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zig_recipe-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for zig_recipe-0.2.0-py3-none-any.whl |
Total release size: 175.0 kB
Release files / zig_recipe-0.2.0.tar.gz
| Download URL | zig_recipe-0.2.0.tar.gz |
|---|---|
| Size | 94.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00ddbf9e1eeb10cc687af2063d171fbe4a7667dfc674950d830102276402199c
|
|
BLAKE2b-256 checksum How to use checksums |
9c2a7c7ab9287c4cca7cf42db6aef022ec2f988e0c650a375572d8815dad0ebc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / zig_recipe-0.2.0-py3-none-any.whl
| Download URL | zig_recipe-0.2.0-py3-none-any.whl |
|---|---|
| Size | 80.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
95dbb117ce04adb0629c53f1798c25f9c5792d856c2adceb3cf2957b4dc9eddb
|
|
BLAKE2b-256 checksum How to use checksums |
03072bb4a241e25f8791b382b0d0cd7b3ac7b416b402488f5a4ca9c459cbf4c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for zig-recipe 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for zig_recipe-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.