opam-repository
opam-repository copied to clipboard
Meta-package for enabling Dune caching
Discussion issue for adding a meta-package for turning on Dune's caching feature from within an opam switch. Dune's caching is discussed in its docs.
Possible names: dune-cache / dune-option-cache / dune-cache-enabled ??
The package would solve four problems:
- Using
setenv, it can exportDUNE_CACHE=enabled(so it manages turning the cache on) - Using
available, it can encode the requirements for opam >= 2.0.8 on Linux and opam >= 2.0.9 on macOS (and any platform-specific requirements) - Using
dependsandconflicts, the required version of Dune can be expressed (especially useful as Windows support arrives) and known versions with caching issues can be conflicted - Packages which for various reasons do naughty things in
_buildcan conflict the dune caching package
The idea seems solid to me.
Packages which for various reasons do naughty things in _build can conflict the dune caching package
If I'm understanding this suggestion correctly, this mean that such packages will not be able to co-exist in a switch caching is enabled? That's a bit of a shame since there's no reason why these can't be installed with caching disabled just for these packages. Perhaps we should just let packages mark if they are incompatible with dune caching inside the dune project itself?
Perhaps we should just let packages mark if they are incompatible with dune caching inside the dune project itself?
That doesn't work for existing releases, though. However, the other possibility for packages which need caching disabled would be to use build-env (instead of conflicts) in the opam file to turn caching off. That can also be applied without a release being needed (and then does allow them to coinstall in switches where caching is turned on).
See https://discuss.ocaml.org/t/ocaml-org-recapping-2022-and-queries-on-the-fediverse/11099/30?u=edwin, for some more useful settings that such a package could do:
setenvDUNE_CACHE_STORAGE_MODE=copy(to avoid EXDEV from the cache inside the opam sandbox, this speeds up opam reinstalls a lot, if opam or the sandbox is updated to no longer require this, it can be removed)- some way to reintroduce automated trimming, perhaps via a new env var? Without it a dune cache can fill an entire disk over several months. (e.g. define both a trim period and size, and if more time has passed since the last trim than defined then perform the trim)