Description
Related issues:
- add tooling to deal with build.zig dependency trees #14288
- new package hash format:
$name-$semver-$hash
#20178 - ability to override packages locally #20180
In order to detect that two different fetched packages represent different versions of the same project, with one intended to supersede the other, we need some kind of stable identifier. Zig package management is decentralized, so there is no global namespace that serves this purpose.
We have the name
field of packages, but it is not globally unique.
... or is it? This proposal takes inspiration from Java's solution to this problem which is to use the domain name system and canonical URIs, so you end up with names such as com.sun.foo.bar.ArrayList
. Although Zig supports URL mirrors, canonical URIs can still be used as globally unique package identifiers.
Example fully-qualified package names would be:
com.github.scottredig.JavascriptBridge
me.andrewkelley.groovebasin
org.codeberg.river.river
org.ziglang.zig
In order to discourage people from fighting over unqualified names and causing general chaos, Zig would emit an error if a package fetched by URL was missing a top level domain name.
Whether the person owns the domain names they use is not enforced. When you choose to add a dependency on a package, you can notice whether they use their own domain name, or someone else's and factor that into the human decision of whether to trust them. Maybe someone decides to take over an abandoned project, and continue using the old maintainer's domain name for the project, for a seamless transition. If that new maintainer has built trust in the community, people would generally find this acceptable.
As for #14288, there would no longer be an id
field introduced. The name
field acts as the globally unique identifier that persists across versions.
As for #20178, only the last path segment in the name would be used. For example:
JavascriptBridge-1.2.3-iDYAACr46GhU
groovebasin-2.0.0-NQ8kAD5eWxrE
river-3.1.0-eTYAAFRBXp0H
zig-0.14.0-cW8vBMOZSHPt
Finally, as for #20180, this could potentially provide a way to override an entire project across the full dependency tree, to quickly find out if a particular patch, for example, could be used to make all the different usage sites of the package satisfied, thus being a candidate for a global override.