Cross-toolchain opam package installer
0

Configure Feed

Select the types of activity you want to include in your feed.

OCaml 94.0%
Perl 4.0%
Dune 0.5%
Other 1.6%
74 1 0

Clone this repository

https://git.vm.fail/gazagnaire.org/opam-x https://git.vm.fail/did:plc:q6kjgf2ankp2z5ohkkwajeug
ssh://git@git.recoil.org:2222/gazagnaire.org/opam-x ssh://git@git.recoil.org:2222/did:plc:q6kjgf2ankp2z5ohkkwajeug

For self-hosted knots, clone URLs may differ based on your setup.


README.md

opam-x#

opam-x installs opam packages into an OCaml findlib toolchain, such as the ocaml-solo5 cross compiler environment, so a local Dune workspace can resolve target libraries with dune -x.

Installation#

This package is not yet in the public opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install opam-x

Usage#

opam install ocaml-solo5
dune-x plan --toolchain solo5 fmt
dune-x install --toolchain solo5 fmt
dune build -x solo5 ./unikernel.exe

opam-x install --dry-run --toolchain solo5 fmt prints the compact package plan without building or touching the cache. opam-x plan --cache-root DIR prints the ocaml-builder derivation graph with cache status.

By default, package layers are cached globally under the XDG cache directory:

$(XDG_CACHE_HOME)/opam-x

or ~/.cache/opam-x when XDG_CACHE_HOME is unset. Pass --cache-root DIR to override it.

Cache partitions include absolute switch paths by default, so identical toolchains installed in different switches do not share layers accidentally. If the installed toolchain package metadata marks the toolchain as relocatable, opam-x omits those absolute paths from the partition key. Use --relocatable-toolchain or --non-relocatable-toolchain to override metadata.

Current Scope#

opam-x resolves the target package closure with nox-opam-solver, computes toolchain-scoped derivation keys with builder.graph, restores cached layers into the selected findlib toolchain, and builds cache misses with Dune using a generated host/target workspace:

dune build --workspace dune-workspace.opam-x -p PKG \
  _build/TOOLCHAIN/PKG-TOOLCHAIN.install

It also has explicit Topkg support for packages that build via pkg/pkg.ml; those are installed with opam-installer into the target findlib directory.

Toolchains#

List the visible findlib toolchains, and the current default, with:

opam-x toolchain list
opam-x toolchain list --long

opam-x list lists the packages installed in a toolchain (from its toolchain.json manifest), selected with --toolchain or the default.

Default toolchain#

opam-x toolchain set NAME makes NAME the default toolchain, so the other commands can drop the --toolchain flag:

opam-x toolchain set solo5    # set the default
opam-x install fmt            # uses solo5
opam-x list                   # packages installed in solo5
opam-x toolchain unset        # clear it

--toolchain on a command still overrides the default for that invocation. The default is a user preference stored under $(XDG_CONFIG_HOME)/opam-x (or ~/.config/opam-x), so opam-x clean does not forget it.