---
name: "opam-module"
section: "5"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["openbsd"]
url: "https://new.carta.tech/opam-module"
---

# opam-module(5)

sysutils/opam port module

## NAME

**opam-module** – sysutils/opam port module

## DESCRIPTION

This manual page documents the behavior of setting MODULES=sysutils/opam in the [ports(7)](/ports/7.md) tree.

The module provides helpers for packaging a program using [opam(1)](/opam/1.md) (OCaml Package Manager).

WRKSRC is expected to contains opam packages, possibly with local customization. All .opam files, at any depth, will be registered. Unmodified dependencies should be omitted, which will be managed separately.

To generate a standalone opam repository containing only the dependencies and the sources files for compiling the specified sources tree, the [make(1)](/make/1.md) **modopam-repository** target should be used. It downloads an opam repository from MODOPAM\_REPO\_URL (defaults to official opam repository hosted on github), using MODOPAM\_REPO\_COMMIT commit (it is preferable to explicitly specify it for reproducibility, but "master" is the default value). The repository is named according to the MODOPAM\_REPO\_NAME variable. Next, the repository is stripped to contain only the build dependencies of MODOPAM\_PACKAGES\_REPOSITORY (default to MODOPAM\_PACKAGES ). After that the repository is filled with a local cache of package archives. The resulting directory can be packaged and distributed. It contains source code for building the opam packages.

External dependencies can be hinted using the [make(1)](/make/1.md) target **modopam-external**. The list of packages expected to be present at build time is shown.

The module appends to BUILD\_DEPENDS unless MODOPAM\_BUILDDEP is set to \`No'.

It sets the MODOPAM\_PACKAGES variable to PKGSTEM, as the default value for opam packages to build and install.

It sets MODOPAM\_OPAMROOT, MODOPAM\_ENV, MODOPAM\_OPAM\_BIN and MODOPAM\_OPAM\_RUN accordingly.

The opam options **---with-doc** and **---with-test** are available using MODOPAM\_WITH\_DOC and MODOPAM\_WITH\_TEST. They default to \`No'.

A CONFIGURE\_STYLE "opam" is provided. It is initialized to opam with the opam repository at MODOPAM\_REPO\_DIR (defaults to *${WRKDIR}/${MODOPAM\_REPO\_NAME}* *).* It is expected to have been generated previously by the **modopam-repository** target and distributed separately. It will also pin the opam packages present in WRKSRC, possibly overriding opam packages from the repository.

A default build target is used (except if MODOPAM\_BUILD is set to \`No'. It uses the MODOPAM\_PACKAGES\_BUILD variable to list the opam packages to build (default to MODOPAM\_PACKAGES ).

A default install target is used (except if MODOPAM\_INSTALL is set to \`No'). It uses the MODOPAM\_PACKAGES\_INSTALL variable to list the opam packages to install (defaults to MODOPAM\_PACKAGES ).

## SEE ALSO

[opam(1)](/opam/1.md), [port-modules(5)](/port-modules/5.md)
