Influence on which repository should be taken first

Someone wrote ocaml/mirage for esp32. He Is has a repository that one should add to install the esp32-version into a specific switch.
When I do a “opam install mirage” it seems that the mirage from the default repository is used. When I remove the default repository some dependencies cannot be resolved. Is there a possibility to tell opam that it should try to resolve the packages from the extra repo first and then from the default one?
I saw there is a possibility to specify a rank to a repository. Is this the way how to do it? What else is needed?

  • Priscine switch (no modules installed)
  • Update?

Thanks for enlighting.

You can do it in multiple ways:

  • Explicitly set the priority when adding a new repository to opam:
    opam repo add NAME --rank 1 ADDRESS

  • If the repository is already added, you can set the priority with opam repo priority NAME RANK

  • You can set the order of your repositories in one command: opam repo set-repos NAME1 NAME2 NAME3, where repo NAME1 will have the highest priority and NAME3 will have the lowest.

Note that packages are looked in the repositories in increasing rank order, so value 1 means the highest priority.