zigfetch

Fetch zig packages, utilizing libcurl.

zigfetch behaves similarly to zig fetch, but utilizing the capabilities of libcurl for its functionality.

HTTP support within Zig's standard library isn't currently stable, this proxy issue make it even harder, resulting in multiple errors occurring during dependency downloads when building Zig projects. This poses a significant challenge for Chinese developers owing to the Great Firewall.

As a consequence, zigfetch was developed. It operates via libcurl to ensure that both the http_proxy and https_proxy environment variables function correctly.

Usage

1
./zig-out/bin/zigfetch --help
 USAGE:
     ./zig-out/bin/zigfetch [OPTIONS] [--] [package-dir or url]

 OPTIONS:
  -h, --help                       Show help
  -V, --version                    Show version
  -v, --verbose                    Show verbose log
  -t, --timeout INTEGER            Libcurl http timeout in seconds(default: 60)
  -n, --no-dep                     Disable fetch dependencies
  -d, --debug-hash                 Print hash for each file

If the argument is a local directory, zigfetch will attempt to open build.zig.zon, download dependencies specified in the .dependencies fields, and then calculate hashes for each package. If these hashes match those in the .hash fields, zigfetch will move them to ~/.cache/zig/p/{hash} after completion.

If zigfetch succeeds, zig build will build the project directly, assuming the dependencies already exist.

Proxy config

This is a demo for socks5 proxy setup:

1
2
3
4
export http_proxy="socks5://127.0.0.1:1080"
export https_proxy=$http_proxy
export all_proxy=$http_proxy
export GIT_SSH_COMMAND='ssh -o ProxyCommand="nc -X 5 -x 127.0.0.1:1080 %h %p"'

GIT_SSH_COMMAND is used for fetch git+http(s) dependencies.

Last modified March 9, 2025: bump 0.2.0 (737e03c)