-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
support fetch plugins to download dependencies from less common protocols #14294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How would this fit into the framework proposed in #14286? It sounds like the goal in that issue is to make it safer to run un-audited |
As a user of IPFS once in a blue moon, here's my 2 cents. If you found a package that for some reason exists only on IPFS, you can
This is applicable to practically any other uncommon protocols and are generally straightforward to implement. It is also guaranteed to work with Zig (it would just see it as normal http/tar). Even without considering security implications - this just seems like a feature creep. Given that the package manager is still in its early development phase, focusing on foundational stability and functionality might be more prudent. I wouldn't expect this kind of feature to be available even in Zig 1.0, let alone 0.13.0 |
This comment was marked as off-topic.
This comment was marked as off-topic.
Agreed, see also my comment at #14298 (comment) |
So, I decided that I try to tackle this over the last few days, so, here is my rather basic proposal. It may have some flaws which I overlooked, but I think it's fine for what one can get without an implementation. It makes it quite easy to e.g. implement Git over SSH (for a few reason which I mentioned in that issue #14295). As for security considerations. The way I have formulated this one could end up restricting it in a way to make it run inside of a sandbox (e.g only access to the network and the target directory and maybe some directory for temporary files), but since for example Git over SSH users often use their SSH keys to connect to the server, I am not sure how practical that would end up being. Anyway, here we go: A fetch plugin is a directory with the following contents:
The plugin is supposed to behave according to the following interface:
Here an quick'n'dirty example: Directory with the files
|
Uh oh!
There was an error while loading. Please reload this page.
Extracted from #14265.
Zig will have built-in support for fetching dependencies from some protocols, such as http, https, gzip, tar, and some others. But there will always be new or exotic protocols. One such example would be ipfs. Not really ubiquitous enough to support directly, but could be interesting for some people to use.
For this I propose a "fetch plugin" system.
Fetch plugins would be specified in build.zig.zon like this:
The url fields within
fetch_plugins
must use a built-in URI scheme or a different fetch plugin from the same manifest.Implementing this proposal will lift out this code from the zig compiler:
zig/src/main.zig
Lines 4080 to 4126 in 7cb2f92
...and move it to a new file
lib/fetch_runner.zig
. This is similar tobuild_runner.zig
andtest_runner.zig
and has the responsibility to fetch the full dependency tree. It will deal with fetch plugins by fetching them, and then rebuilding the fetch runner itself, multiple times if necessary, until everything is fetched.Once everything is fetched, build_runner.zig proceeds as usual. Note that in the case when everything is already fetched, the fetch_runner will not be executed because the open() syscalls on the first-level dependencies based on their hashes all succeeded.
The text was updated successfully, but these errors were encountered: