Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/languages-frameworks/ocaml.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@ packaged libraries may still use the old spelling: maintainers are invited to
fix this when updating packages. Massive renaming is strongly discouraged as it
would be challenging to review, difficult to test, and will cause unnecessary
rebuild.

The build will automatically fail if two distinct versions of the same library
are added to `buildInputs` (which usually happens transitively because of
`propagatedBuildInputs`). Set `dontDetectOcamlConflicts` to true to disable this
behavior.
13 changes: 13 additions & 0 deletions pkgs/development/tools/ocaml/findlib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,26 @@ stdenv.mkDerivation rec {
mkdir -p $OCAMLFIND_DESTDIR
fi
}
detectOcamlConflicts () {
local conflict
conflict="$(ocamlfind list |& grep "has multiple definitions" || true)"
if [[ -n "$conflict" ]]; then
echo "Conflicting ocaml packages detected";
echo "$conflict"
exit 1
fi
}

# run for every buildInput
addEnvHooks "$targetOffset" addOCamlPath
# run before installPhase, even without buildInputs, and not in nix-shell
preInstallHooks+=(createOcamlDestDir)
# run even in nix-shell, and even without buildInputs
addEnvHooks "$hostOffset" exportOcamlDestDir
# runs after all calls to addOCamlPath
if [[ -z "''${dontDetectOcamlConflicts-}" ]]; then
postHooks+=("detectOcamlConflicts")
fi
'';

meta = {
Expand Down