I’m fiddling today with the build system and something bugs me.
(for context I’m trying to compile a Qt hello world via zig and fetch qt libs via the build system. Might or might not be a bad idea, but it’s not necessary directly relevant)
Problem statement :
I have http://random_mirror_im_not_fully_confident_with.com/tarball.tar.xz
I also have a md5sum for tarball.tar.xz on the official website, so I want to check.
I can do this by hand, so far so good.
If I use the url directly as .url in the build.zig.zon, zig will nicely and helpfully download the source, extract it and provide a .hash = ... for me.
(btw : I love the scheme of 0.16 that gives you both an easy to reach inflated folder and a canonical re-compressed version in the global cache, but I digress)
Now, what bugs me is how do I make sure the stuff zig downloaded is what’s expected ? I have zig’s provided hash that “protect” whatever is in zig-pkg, but it’s inflated and cannot run a md5sum on the folder.
I was thinking I could download manually, run the checksum, manually inflate and point .path = ... in the zon file but in that case the .hash = is not used as far as I know. So while working for me locally, I could not switch to upstream fetching with the same confidence.
It feels like zig is encouraging me to blindly fetch this stuff and this feels wrong that zig is not pushing me toward good practice.
Am I missing something obvious ? Does it seems a legit concern ? How would you address this ?
Digression - where I just want to babble on software dependencies
The stuff above is pretty low stakes in my little experiment, but I'm genuinely surprised feeling zig pushing me toward not doing the right thing. I'm following zig closely for some years now, while the "this is hard" feeling has been common, "this is wrong" feeling is new (or crazy rare at least)Supply-chain attack becomes more of a concern by the day lately, and it seems to me the package manager model “à la” pip/npm etc.. will become unsustainable.
But boy ! The convenience ! Manual dependency management is a hard sell in comparison (until you have catastrophic ecosystem collapse of course, because trust is gained slowly but breaks fast…)
Anyways, I find zig’s approach so interesting (as usual tbh). Strategic friction where the bad idea is just slightly harder to do. Let’s offer convenience in the usage, but still force manual authoring of dependencies. It’s a fine line to walk, and the “decentralized but fingerprinted” road taken by zig so far delighted me.
But the example above made me realize that just blindly zig fetch is a big temptation, and … Not sure honestly, just had to put that out somewhere I guess.
Note that I’m not saying zig fetch --save is a bad idea. It’s a brilliant QoL feature. But it makes me wondering if something is in a local optimum here …
Anyways, love zig ![]()