Normally when a package has dependencies, all of them need to be provided for it to build successfully.
This proposal is about adding a mechanism that would allow to specify a dependency that can be satisfied by any package in a list of alternatives. The package manager at this point would be able to choose which element to provide based on a set of internal rules.
Since we haven't chosen yet a text format for enumerating dependencies, I'll use everyone's favorite to provide a concrete example. The syntax is not meant to be well designed, just focus on the semantics of the example.
tcp-client:
version: 1
deps:
- iguanaTLS@v2.2
http-client:
version: 1
deps:
- http-parser@v1
- ssl: oneOf:
- iguanaTLS@v2
- libressl@v2
- bearssl@v2
elazig-search:
deps:
- bearssl@v2
- http-client@v1
monzigdb:
deps:
- tcp-client@v1
- http-client@v1
So in this example you can see that http-client can use any of the mentioned tls libraries and how that can be useful to reduce the total number of dependencies when used by elazig-search and monzigdb.
More in general this feature could help the creation of "interface packages": packages whose only job is to extract a common interface from a set of concrete implementations for consumers that really value avoiding getting locked into a specific dependency. I think more could be said about the value of this practice but it's a bit outside of the scope of this proposal.
Not covered here but also necessary, is the ability to orchestrate the different optional dependencies in the Zig code (eg how can I add a conditional that depends on which dependency was fulfilled?).
Normally when a package has dependencies, all of them need to be provided for it to build successfully.
This proposal is about adding a mechanism that would allow to specify a dependency that can be satisfied by any package in a list of alternatives. The package manager at this point would be able to choose which element to provide based on a set of internal rules.
Since we haven't chosen yet a text format for enumerating dependencies, I'll use everyone's favorite to provide a concrete example. The syntax is not meant to be well designed, just focus on the semantics of the example.
So in this example you can see that
http-clientcan use any of the mentioned tls libraries and how that can be useful to reduce the total number of dependencies when used byelazig-searchandmonzigdb.More in general this feature could help the creation of "interface packages": packages whose only job is to extract a common interface from a set of concrete implementations for consumers that really value avoiding getting locked into a specific dependency. I think more could be said about the value of this practice but it's a bit outside of the scope of this proposal.
Not covered here but also necessary, is the ability to orchestrate the different optional dependencies in the Zig code (eg how can I add a conditional that depends on which dependency was fulfilled?).