-
Notifications
You must be signed in to change notification settings - Fork 368
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 defaults configuration file #2930
Conversation
This was my impression aswell, see this discussion. To sum up I would have liked to have named sets of package constraints and variable definitions that are opam managed and either created locally or distributed via repositories or read from an This could simplify this whole switch init business while at the same time providing a solution to the problem of scaling switch management to local repos: sharing team setups via repositories, having the dev tools you'll need in all your switches under a I think that with such a scheme you could even eschew the redefinitions via |
Thanks for the work on There are a few things I am not yet sure about:
Besides these points, I think the chain of config files is a good idea, and the proposed format is OK. Other parameters of switch initialisation that could be included in the file include:
An idea was to allow that file in source dirs too, so that it could select appropriate parameters for |
Note: I recently added the ability to do |
Just a quick note: would it make sense to have simple "scripts" to setup the switches, instead of yet-an-other adhoc format? Eg. a simple file with:
(where each line is understood as an |
@AltGr - The switch-variables don't really depend on package variables. The only package variable available is You can definitely still set-up an empty switch here - on my x64 system with an x86 OCaml system compiler, it just means that I must run |
@dbuenzli, @AltGr - in principle, the idea of including packages for each possible set of switch variables is a solution, but it results in a vast explosion of the number of compiler packages which would mean the ocaml packages would definitely not be maintainable by hand - for Windows alone, it adds 6 packages for each version, quadrupled once you take the safe-string and flambda variants into account (and exponentially as you add spacetime, etc.). It might also mean that opam-repository suddenly has to be aware of other exotic architectures (in order to have packages for them), rather than just having default cases in configure scripts. I'm rather seeing this feature as way of reducing the number of package variants - e.g. no longer requiring +flambda, +32bit, +spacetime, +safe-string etc. If these variables (or the triple, etc.) end up being used, my feeling is that they should have some kind of easily discoverable documentation. While nice and generic, |
@AltGr - the only problem with determining the compiler package from the variables (rather than the other way around) is that are various configurations which would make discovering the ocaml-system compiler harder. Again, on my x64 machine you would always have to do |
@AltGr - I think the behaviour for having multiple repository with configuration files is entirely related to chaining them already so even though I don't necessarily think we have to have repository-based configuration files, I don't think this problem is simplified just by not permitting them. For example, if I define a single entry in |
@samoht - I don't think it's a bad idea, though it does have an initial feeling of replacing one ad hoc format with another! The idea with the switch-defaults file was that the fields are at least consistent with those in opamrc format (and @AltGr is principally suggesting moving additional fields from .opamrc to this file) |
OK, assuming this passes CI - I have added (I think correctly) @AltGr - how's this looking so far? I think that command line overriding (or not) of variables and more complex schemes for merging/locating switch configuration files can be further work on top of this? |
It's not clear to me whether the Travis failures are down to this PR or something else? |
Yes, I've read the code and it looks fine (just a note on formatting: I don't have a strict policy on 80 cols, although I try to stick to that, but please avoid very long lines ☺). About using Yes, a finer way to merge config files would be nice to have. I could see three options: whole-file replace, per-field replace (the current setting), and per-field append on list fields (replace on others). You could already simulate whole-file replace by explicitely disabling built-in and standard conf files; @samoht: the general format is well-defined and consistent with the rest, and has the benefit of allowing our expressive syntax for filters, for example. If you want to avoid anything adhoc, you could still resort to a shell script indeed, which would actually be quite close to what you propose ;) |
There were some heinously long lines in there, sorry! I've pushed amended commits which I think limit lines to a maximum of 90 chars (the odd function definition I think left as-is). But the stupidly long functionals are now broken sensibly! Another thought I had on the naming of the For merging the files, what I was thinking was something along the lines of fields used in things like JSON-schema. So having some kind of field which listed changes which should happen to the "parent" file. It's not that I necessarily think it is useful right now, but a major upgrade to the format seems the time to consider changes like that (it's outside the scope of this PR for now, though - perhaps I'll bring it up again for +beta99 😉). It's a fine balance between adding so much configurable power that it's next to impossible to use (e.g. httpd.conf....) vs not enough so that you end up needing to write wrapper scripts around it. |
8c75563
to
2ad5da8
Compare
1d0b722
to
c548064
Compare
@AltGr - please could you restart the AppVeyor build (I'm pretty sure that's a transient error) |
The error seems to be persistent :/ ?? |
It's passed now?! |
1f69690
to
21f1e1c
Compare
21f1e1c
to
f47ee60
Compare
4b46e01
to
99035f5
Compare
99035f5
to
bfe26bc
Compare
Add a new format for switch-specific global variables along the lines of the the "global-variables" field in /etc/opamrc. This new field "switch-variables" is added to a configuration type "switch-defaults" which may be embedded as a section in /etc/opamrc. The motiviation here is to be able to specific switch-specific global variables which can be fed to opam switch create either by the command line or by specifying an alternate configuration file. Signed-off-by: David Allsopp <david.allsopp@metastack.com>
Default switch configuration (empty, at present) Signed-off-by: David Allsopp <david.allsopp@metastack.com>
opam switch create now also supports the --default-config and --config also found in opam init. For opam switch create, --config specifies a switch-defaults file, not an opamrc, but if not specified, opam will look for a switch-defaults section in opamrc. Signed-off-by: David Allsopp <david.allsopp@metastack.com>
Was there any decision on this pull request? Two years passed already... |
Please note at this stage that I'm not interested in any discussion/opinion regarding the variables added in 37d477a, as that whole bit is still being separately worked on (TL;DR I expect to replace them with a single triple/quartet variable)!
However, I'm extremely keen to hear opinions on the rest of this! This GPR adds a new format
OpamFile.SwitchDefaults
which allows the following kind of file to be set-up:This list of variables is then filtered at
opam switch create
and added to the switch configuration as normal. The default switch configuration can be embedded into /etc/opamrc as aswitch-defaults
section and an example of this is included in 37d477a. There are two areas (in addition to general comments on how this is working) where I'd appreciate some further input:Locations to search for switch initialisation files
So far, we have
~/.opamrc
and/etc/opamrc
(as well as the ability to specify a file foropam init
to use). I am therefore wondering if theopam init
process should write theswitch-defaults
file (e.g. to~/.opam/opam-init/switch-defaults.config
) or whether we should just have a new chain of files (so look for~/.opam/opam-init/switch-defaults.config
, then theswitch-defaults
section of~/.opamrc
, then theswitch-defaults
section of/etc/opamrc
).I was also wondering whether we should be considering having switch-defaults files in repositories - the variables set-up here are to with opam being used for OCaml - should really be homed in the default repository? Indeed, it makes me wonder whether the proper home for
sys-ocaml-version
, etc. is really a configuration file in opam-repository, and not in OpamInitDefaults at all? Doing this also brings up the important question of how these configuration should be merged or overridden. But it has the nice property that if, say, you have an opam set-up mixing OCaml switches and Coq switches that the action of declaring a new switch with the Coq repository would automatically set that switch up with the switch global variables which a Coq installation might expect (but this may need to worry about merging theswitch-variables
lists of both Coq and OCaml).Ability to override switch-variables at
opam switch create
In addition to being able to specify a switch-defaults configuration file at
opam switch create
, it should clearly also be possible to specify values of particular variables atopam switch create
(effectively providing a mechanism foropam config set
). I would propose adding a further field toswitch-defaults
:opam switch create
would use this file to generate--conf-switch-arch
,--conf-switch-cc
and--conf-switch-libc
including both validation of the values which can be given and also help text. For my Windows work, this then provides a truly generic way to haveopam switch create 4.04.1-msvc32 --packages=ocaml --conf-switch-arch=i686
(rather than my earlier prototypes where--arch
,--cc
and--libc
were hard-coded options)