-
Notifications
You must be signed in to change notification settings - Fork 375
Spec for Extended package specific variables
Kate edited this page Apr 10, 2023
·
6 revisions
Wrt https://github.com/ocaml/opam/issues/4526 we discussed the possibility of using the available field to resolve this problem instead of having yet another flag.
This would make the behaviour independent of the version of opam as undefined variables are false by default.
-
Add a new option
--set <var>[=<value>]toopam install,opam reinstall,opam upgradeandopam switchwhich would:- set a variable defined only for the packages listed explicitly by the command above used
- said variable would be stored in
<switch-prefix>/.opam-switch/config/<pkg>.configthe same way<pkg>.configare. The variables passed as argument would override any variables from the<pkg>.configfile if there is any. - said variable would be treated the same way as usual packages variables (coming from .config files)
-
Broader changes to packages variables:
- packages variable from the current package (aka.
_:var) can now be used in theavailablefield -
with-testandwith-docwould become shorthands for_:with-testand_:with-docrespectively and the --with-{test,doc} argument would become shorthands for--set with-{test,doc} - Package variables can also be set before even installing the package with
opam var pkg:var=value. However trying to do that on currently installed packages would result in an error.
- packages variable from the current package (aka.
-
Later features:
- Default global values for package variable could be added as a feature later (e.g.
opam var _:with-test=truewould make any future packages compile the tests as well) - We could detect new values when calling
opam install --set var=new-value pkgand rebuild pkg if the value ofvaris different from the one installed.
- Default global values for package variable could be added as a feature later (e.g.
This would be very useful for:
- Making packages unavailable: changing the package for it to be
available: _:manual | !(os-family = "alpine" | os-distribution = "centos")for instance so that people can still install it if they have things set up locally, but would be unavailable by default. People would just have to callopam install --set manual <pkg>if they sure they really want it. This would also remove any use forx-ci-accept-failuresin CIs that support it. - This would make opam finally on-par to gentoo's USE flags (https://www.gentoo.org/support/use-flags/) — superior even, as USE flags do not carry values — and would open possibilities such as:
opam switch create --set use-flambda 4.12.0and would remove any use ofconf-option-*packages.
-
_:varinavailable:will return an error when added using opam 2.0 and 2.1- To test: Is
vara shorthand for_:var?
- To test: Is
-
_:varisn'tfalseby default, it's undefined. Which means that in opam 2.0 and 2.1,build: ["true"] {_:var}andbuild: ["true"] {!_:var}will do the exact same thing (not do anything)- Solution:
?var & varwill give the right result
- Solution:
Statically known variables:
- Defined in advance (it's better if there are listed in a new "vars" field for example but not mendatory)
- Can be used to mess with dependencies safely (known before solver call)
<pkg>:name<pkg>:pinned-
<pkg>:bin&<pkg>:sbin&<pkg>:lib&<pkg>:man&<pkg>:doc&<pkg>:share&<pkg>:etc
Dynamically known variables:
- Unsafe to use in
depends,depexts,depoptsandconflicts(requires multi solver calls) - e.g. everything set on the fly in
<pkg>.configfiles <pkg>:version<pkg>:depends<pkg>:installed<pkg>:enabled<pkg>:build<pkg>:hash<pkg>:dev<pkg>:build-id<pkg>:opamfile
Could default values for dynamically set variables help? Something like:
variables: [
[bytecode-only = false]
32bit
...
]