Skip to content

feat(pkg): support opam repository archive mirrors - #15615

Draft
Alizter wants to merge 1 commit into
ocaml:mainfrom
Alizter:pkg-opam-archive-mirrors
Draft

feat(pkg): support opam repository archive mirrors#15615
Alizter wants to merge 1 commit into
ocaml:mainfrom
Alizter:pkg-opam-archive-mirrors

Conversation

@Alizter

@Alizter Alizter commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Read archive-mirrors from an opam repository root repo file and resolve relative mirror URLs against the repository.
  • Store mirrors in lock-directory archive sources so builds remain independent of the repository checkout.
  • Fetch checksum-addressed mirror objects before the original archive URL, verify every result, and fall back on mirror misses or corruption.
  • Configure the built-in opam repository with https://opam.ocaml.org/cache.

Related Issue and Motivation

Opam repositories can provide stable archive mirrors for packages whose upstream source is unavailable or flaky. Dune package management currently ignores this metadata and always starts with the upstream URL.

Fixes #13130

Testing

  • ./dune.exe build @check @fmt
  • ./dune.exe runtest test/blackbox-tests/test-cases/pkg/archive-mirrors.t
  • ./dune.exe runtest test/expect-tests/dune_pkg
  • ./dune.exe runtest test/blackbox-tests/test-cases/pkg/compute-checksums-when-missing.t
  • Smoke-tested a dune init project lock/build against the central opam cache.

The full @runtest gate currently reaches three unrelated watch-mode tests that time out on their first RPC build in this local environment.

Checklist

  • Tests added, if applicable.
  • Change log entry added for any user-facing changes.
  • Documentation added for any user-facing changes (not applicable: this follows existing opam repository metadata).

@Alizter
Alizter force-pushed the pkg-opam-archive-mirrors branch from 8dcd64d to 72d7f77 Compare July 29, 2026 09:00
Read the archive-mirrors field of opam repository metadata, record the
mirrors in lock directories, and try checksum-addressed mirror objects
before a package's primary source URL, falling back to the next mirror
or the primary URL on failure or checksum mismatch.

Design notes:
- Local (file) sources are read directly and never consult mirrors.
- Pinned packages never consult mirrors: pinned means pinned.
- Mirrors are not part of the fetch action digest since they cannot
  change the produced content.
- Relative mirror entries are skipped for git-backed repositories, and
  unsupported mirror schemes are dropped with a warning at solve time.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
@Alizter
Alizter force-pushed the pkg-opam-archive-mirrors branch from 72d7f77 to a61a9d3 Compare July 29, 2026 09:08
@rgrinberg

Copy link
Copy Markdown
Member

First, the change to the lock dir should be added and tested separately.

Second, I find that the approach used to support this feature not to be consistent with the rest of the dune language. A more straightforward and flexible approach is to list more than 1 url in a fetch and allow dune to try them in sequence. The concept of an "archive mirror" need not leak at all to lock directories themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dune should support archive-mirrors for opam-repos

2 participants