-
Notifications
You must be signed in to change notification settings - Fork 358
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
Switch and package configuration variables #2247
Comments
Related to #2245 |
Should it be /cc @mato to check that the proposal could help to cross-compile to rumprun. |
Yes, updated.
What do you mean exactly ? I don't think cross-compile is in reach before |
Ok but not exactly that way since |
Thanks!
¹ it's natural after moving the actual compilers to packages. The main motivation is not to duplicate all signature and validation mechanisms for both package and compilers, which is a very different hierarchy and file naming conventions. |
I don't know exactly what your plans are but don't you think you'd still need some kind of switch description file ? If that's the case that seems to be the right place to describe the switch variables. If you think you can eschew the switch description file and that packages create switches (how ? via information provided by a field ?) then yes we can merge the two notions and have switch creating packages define the global variables through their own
This was also a question I had. Reading again about them in the dev manual, it seems to me that we could replace them by this.
Ah yes. Can't we simply union the variables found in the descriptions.
Maybe having a
Why not ? I think that not checking this is going to bring more problems in by propagating wrong information in the system. Packages can have different output variables for different versions as described by their opam files, I don't see this as a problem. Besides I think that usage of an undefined output variable by another package should also make its install fail.
I'm not talking about |
features vs. config vars: features are not used at all at the moment and they might be a bit too complex ; if it turns out the functionality is indeed included in config vars, the simpler alternative is fine with me.
Rather, this could be detected statically. My concern is that it adds failure to a package's definition depending on what's in another package ; e.g., your package could get broken because a new version of a dependency that doesn't define some variable anymore. While this is obviously the case for code, it isn't the case for package definitions as of now. |
on the switch/package: I am still thinking about how it should be done. Indeed some specific fields (or flags) could allow opam to recognise switch options within the set of package definitions... |
I don't understand the concern here. I fail to see how this is different from an API break: the other package changed the way it works by no longer exporting a package state variable in its definition which makes it incompatible with my package since I was actually using that package state variable to configure myself. E.g. suppose I'm using |
On Tuesday, 07.07.2015 at 11:47, Daniel Bünzli wrote:
This is currently set by the user at
Note: I will be changing the RUMPRUN_PLATFORM name, probably to RUMPRUN_TOOLCHAIN_TUPLE, as we have now standardised on "platform" to mean "target board or hypervisor" in the context of rumprun. This variable does not have a meaningful default, it depends on which toolchain(s) the user may have available. If I understand this proposal correctly, then this could be a per-package input variable? Regarding the global ocaml-rumprun-* variables that the package sets, these can probably be reduced to a single Provided this output variable is accessible to all packages during build, it can be a per-package variable instead of a global variable. The variable is required during the build process in order to install the cross-compiled packages in a separate directory namespace in the switch, so that the cross-built packages do not conflict with native packages in the same switch. It is also required for some packages which build C code in order to know which toolchain to use. On a related note, I would like to document the cross-compilation internals and start a discussion on how to improve OPAM support for this going forward. Is this best had on opam-devel or in a Github issue? |
Yes.
Yes. It's just that you'll need to prefix it with the name of the package, i.e.
I think it's better if we start with a discussion on the mailing list. FWIW I unsucessefully started one last week here. You are also welcome to comment on my cross-compilation support ideas for assemblage here. |
On Thursday, 09.07.2015 at 04:40, Daniel Bünzli wrote:
Ok. Why the constraint on input and output variables not having the same |
Because a reference to |
I ended up here by chance and am wholly unqualified to comment on OPAM's design, but given that I read this interesting proposal I may as well make some (probably naive) comments.
This is a typo and you mean
Well at least it would be very useful if packages stored the ambient state at the time of their installation. It is rather common to have users report "if installed X but cannot do Y, why?" with the answer being "Z is not configured on your system so Y was opted out"; not being able to debug these situations by knowing for sure the state available at installation time would be a pain. The command (As a user I thought it would be nice if, as a special case,
This looks like a major shooting-yourself-in-the-foot opportunity. It would be much safer to have a
What is the command to list all variables set for a given package? (Is there a command that shows the variable values, but also their documentation strings? It may be useful to have an
Could we explicit set and get variables for some specific version of the package only? |
Parts of this are now here. Still missing:
So the proposal still makes sense as it is. Input variables could be quite useful. |
Switch and package configuration variables
Switch and package configuration variables are respectively per switch and per package key-values bindings that can be accessed in opam files to configure packages.
Configuration variables come in two flavors, input and state variables. The difference being that input variables can be set by the opam end-user (they express a configuration desire) while state variables are usually defined by the result of install processes (they express a configuration reality).
More precisely for package configuration variables:
For switch configuration variables:
Note that both input and state variables share the same namespace. It is not possible to declare both an input and state variable with the same name.
Also note that the current value of an input variable says nothing about the current install state of a switch or a package as they may be set by the end-user at any time without further side-effects. (N.B. if we had precise dependency tracking of variables in the opam files we could actually reinstall any package that depends on a variable whenever it is changed, but that may not be desirable either).
Input variable declaration
Switch input variables are defined in the switch's
.comp
file and package input variables are defined in the package'sopam
file via theconfig-input-vars
field as follows:That is each input variable needs to define a name, a default value (which can be a variable interpolated string, e.g. in a package it can refer to a switch input variable) and a documentation
string. Example:
State variables declaration
State variables are defined in the switch's
.comp
file and the package'sopam
files via theconfig-state-vars
variables as follows:That is each state variable needs to define its name and a documentation string.
For packages, the package must then define the value of each of the declared variables by installing a
opam.config
file with the package in itslib
directory, i.e.$opam/$SWITCH/lib/$PKG/opam.config
.It is an install error if the package declares a state variables and fails to define it in its
opam.config
file.FIXME I know less about the switch install procedure but I guess something similar could be done.
Setting input variables
Input variables can be set by using the following invocations:
For packages this commands writes the
$VAR
to$VALUE
binding in$opam/$SWITCH/config/$PKG.config
file. For switches it does so in the file$opam/$SWITCH/config/global-config.config
. The invocations error if$VAR
is not declared in the package's or switch'sconfig-input-vars
field.Input variables can be reset to their default state using:
Invoking this command resets the value of
$VAR
to the one that is declared in theopam
or.comp
file. If$VAR
is unspecified all the input variables are reset. The invocations error if$VAR
is not declared in the package or switch'sconfig-input-vars
field.Getting configuration variables
Both input and state configuration variables can be accessed using the following invocation:
They can also be used in the fields of
opam
files that support string interpolation to get their value by using$PKG:$VAR
and$VAR
. The invocations error if$VAR
is not in declared in one of theconfig-*-vars
field.The text was updated successfully, but these errors were encountered: