# `zig_package_source`

Acquires one specified Zig package and verifies its native tree hash before publishing a cacheable output. Normally generated by [`zig_dependencies`](/reference/prelude/zig_dependencies).

## Attributes

| Attribute | Type | Required | Meaning |
| --- | --- | --- | --- |
| `url` | string | yes | Source URL or local archive/directory path |
| `hash` | string | yes | Expected native Zig package tree hash |
| `zig` | string | no | Zig compiler; defaults to `zig` on `PATH` |

The `sources` dependency role accepts artifact producers containing a local archive. Declare local source bytes in `srcs` as well as the producer edge.

## Providers

- `artifact`, whose root is `fetch/zig-pkg/<hash>` beneath the target's output directory.

The build action invokes `zig fetch` once in a dependency-free scratch project with a private native cache. It uses `copied-inputs` sandboxing because native tree hashing distinguishes regular files from staged symlinks. The declared output must exist under the expected native hash, so a mismatched fetch cannot publish a successful cache result. It does not recursively acquire children, choose dependencies, modify the workspace's native store or rewrite `build.zig.zon`.

The source URL, pin and Zig tool identity participate in caching. Different mirror URLs currently acquire separately; cache reuse across different compiler installation paths is not guaranteed. Recursive discovery is experimental and needs complete graph replay before query and affected-test results can describe the entire acquired graph.
