|
| 1 | +--- |
| 2 | +.title = "Community Mirrors: A Better Way To Download Zig", |
| 3 | +.date = "2025-06-30", |
| 4 | +.author = "", |
| 5 | +.layout = "news-page.shtml", |
| 6 | +.custom = { |
| 7 | + "mobile_menu_title": "Community Mirrors", |
| 8 | +} |
| 9 | +--- |
| 10 | + |
| 11 | +With Zig being in active development, it's pretty common to need to download new Zig compiler releases, particularly if you track the "master" pre-releases |
| 12 | +instead of tagged releases. There are also some situations where you might want to re-fetch the *same* Zig version, such as stateless CI runs. This brings us to |
| 13 | +what might seem like a trivial problem: *how do you actually download Zig*? |
| 14 | + |
| 15 | +The obvious way to do this has always been to download the tarball from ziglang.org. However, this website is hosted on an [intentionally simple |
| 16 | +configuration][self-hosted-website], with the intention of optimizing overall efficiency rather than expending huge amounts of resources on web hosting. So, to |
| 17 | +avoid excessive load, we've previously publicly recommended that people use mirrors to download Zig where possible, and we [cryptographically sign our |
| 18 | +tarballs][minisign] to make this approach more viable. The official Zig website doesn't provide any uptime or bandwidth guarantees, so download mirrors actually |
| 19 | +*directly benefit users* by potentially improving availability and speed. |
| 20 | + |
| 21 | +There's just one problem: so far, there haven't really been any mirrors available to use. This began to change last year, when the [setup-zig][setup-zig] |
| 22 | +project became the first widely-used project to actually utilize download mirrors for Zig tarballs. However, they weren't easily accessible to other projects, |
| 23 | +who didn't want to take on the burden of maintaining their own mirror lists. |
| 24 | + |
| 25 | +**To solve this, we're introducing Community Mirrors.** |
| 26 | + |
| 27 | +The idea is simple. Instead of downloading tarballs from ziglang.org, automations should instead fetch from it a small text file, maintained by the Zig core |
| 28 | +team, which contains URLs of community-run mirrors. This takes the burden off of others to maintain their own lists of mirrors, so makes it simpler for tools to |
| 29 | +*efficiently* download Zig. We also have some [nify automated testing][check-mirrors] to make sure that all of the mirrors are behaving, so there's no risk of |
| 30 | +problems with a mirror going unnoticed. |
| 31 | + |
| 32 | +The Download page now contains a link to the new [Community Mirrors][mirrors] page, which explains how to use the mirrors in your code -- please check it out if |
| 33 | +you've written code which downloads Zig. The process boils down to fetching the mirror list (which is just plaintext ASCII with one URL per line), shuffling it, |
| 34 | +and attempting each mirror in turn before falling back to ziglang.org. **You must verify the cryptographic signature of tarballs downloaded from mirrors** -- |
| 35 | +because they are hosted by third parties, a mirror could theoretically serve you malicious or corrupted files. |
| 36 | + |
| 37 | +If you have the resources and time, a great way to contribute to the Zig ecosystem is now to [host your own mirror][host-mirror]. You don't need any specific |
| 38 | +experience or permission: just check out that link. Hosting a download mirror helps to keep Zig accessible as it grows in popularity, and shouldn't need too |
| 39 | +much ongoing maintenance. |
| 40 | + |
| 41 | +That's all for today. Thanks folks! |
| 42 | + |
| 43 | +Matthew |
| 44 | + |
| 45 | +[self-hosted-website]: /news/migrate-to-self-hosting/ |
| 46 | +[minisign]: https://jedisct1.github.io/minisign/ |
| 47 | +[setup-zig]: https://github.com/marketplace/actions/setup-zig-compiler |
| 48 | +[check-mirrors]: https://github.com/ziglang/www.ziglang.org/actions/runs/15976134096#summary-45058979620 |
| 49 | +[mirrors]: /download/community-mirrors/ |
| 50 | +[host-mirror]: https://github.com/ziglang/www.ziglang.org/blob/main/MIRRORS.md |
0 commit comments