OPAM files generated by Dune do not contain an install: field by default as .install files are used instead. However, you can inject arbitrary fields into the generated OPAM file by putting them in a file called $PKGNAME.opam.template at the root of the Dune project. So something like
# dune-project
(lang dune 3.18)
(package (name mypkg))
(generate_opam_files)
# mypkg.opam.template
install: [
"cmdliner" "install" "tool-support"
"--sharedir=%{share}%" "--mandir=%{man}%"
"_build/install/default/bin/thetool" "%{prefix}%"
]
could be a starting point (here mypkg is the name of the package). Note that you need to write the path to the built tool by hand (here, _build/install/default/thetool). (Also, you may have some issues on Windows if cmdliner install tool-support does not handle the .exe extension automatically.)
I’m assuming here that OPAM is able to work with packages that have both an .install file and an install: field in their OPAM file.
Sorry I can’t give more precise instructions, but am not really an OPAM user. cc @Alizter or @maiste who may be able to give you more details.
Cheers,
Nicolas