Can I have arbitrary text fields in a proj.opam file? Can it be converted to json too if I want?

I want to put arbitrary fields that point to arbitrary strings in my .opam file without installs failing. Is this possible? Can it be made into json?

Worst case I suppose in the description field I can insert a .json files as a string if I want…sounds hacky.


For json worst case I suppose one can always loop through each like and the NAME is the key and → is the value. A tool that does this for me or a paraser for opam files that exists already would be nice.

Yes you need to prefix them with x- see the manual.

1 Like

amazingly helpful! <3 @dbuenzli

Are there tools that translate opam files to more universal formats like .json files?

See GitHub - tweag/opam2json.

Also, OPAM files can be modified using the OPAM libraries, they can read OPAM files, modify OPAM files and also output OPAM files, which might be a bit simpler than converting to JSON and back.