1# build.zig.zon Documentation
2
3This is the manifest file for build.zig scripts. It is named build.zig.zon in
4order to make it clear that it is metadata specifically pertaining to
5build.zig.
6
7- **build root** - the directory that contains `build.zig`
8
9## Top-Level Fields
10
11### `name`
12
13Enum literal. Required.
14
15This is the default name used by packages depending on this one. For example,
16when a user runs `zig fetch --save <url>`, this field is used as the key in the
17`dependencies` table. Although the user can choose a different name, most users
18will stick with this provided value.
19
20It is redundant to include "zig" in this name because it is already within the
21Zig package namespace.
22
23Must be a valid bare Zig identifier (don't `@` me), limited to 32 bytes.
24
25Together with `fingerprint`, this represents a globally unique package identifier.
26
27### `fingerprint`
28
29Together with `name`, this represents a globally unique package identifier. This
30field is auto-initialized by the toolchain when the package is first created,
31and then *never changes*. This allows Zig to unambiguously detect when one
32package is an updated version of another.
33
34When forking a Zig project, this fingerprint should be regenerated if the upstream
35project is still maintained. Otherwise, the fork is *hostile*, attempting to
36take control over the original project's identity. The fingerprint can be regenerated
37by deleting the field and running `zig build`.
38
39This 64-bit integer is the combination of a 32-bit id component and a 32-bit
40checksum.
41
42The id component within the fingerprint has these restrictions:
43
44`0x00000000` is reserved for legacy packages.
45
46`0xffffffff` is reserved to represent "naked" packages.
47
48The checksum is computed from `name` and serves to protect Zig users from
49accidental id collisions.
50
51### `version`
52
53String. Required.
54
55[semver](https://semver.org/)
56
57Limited to 32 bytes.
58
59### `minimum_zig_version`
60
61String. Optional.
62
63[semver](https://semver.org/)
64
65This is currently advisory only; the compiler does not yet do anything
66with this version.
67
68### `dependencies`
69
70Struct.
71
72Each dependency must either provide a `url` and `hash`, or a `path`.
73
74#### `url`
75
76String.
77
78When updating this field to a new URL, be sure to delete the corresponding
79`hash`, otherwise you are communicating that you expect to find the old hash at
80the new URL. If the contents of a URL change this will result in a hash mismatch
81which will prevent zig from using it.
82
83#### `hash`
84
85String.
86
87[multihash](https://multiformats.io/multihash/)
88
89This is computed from the file contents of the directory of files that is
90obtained after fetching `url` and applying the inclusion rules given by
91`paths`.
92
93This field is the source of truth; packages do not come from a `url`; they
94come from a `hash`. `url` is just one of many possible mirrors for how to
95obtain a package matching this `hash`.
96
97#### `path`
98
99String.
100
101When this is provided, the package is found in a directory relative to the
102build root. In this case the package's hash is irrelevant and therefore not
103computed. This field and `url` are mutually exclusive.
104
105#### `lazy`
106
107Boolean.
108
109When this is set to `true`, a package is declared to be lazily fetched. This
110makes the dependency only get fetched if it is actually used.
111
112### `paths`
113
114List. Required.
115
116Specifies the set of files and directories that are included in this package.
117Paths are relative to the build root. Use the empty string (`""`) to refer to
118the build root itself.
119
120Only files included in the package are used to compute a package's `hash`.