summary refs log tree commit diff
path: root/pkgs/development/tools/ocaml
diff options
context:
space:
mode:
authorGuillaume Girol <symphorien@users.noreply.github.com>2023-01-27 20:18:39 +0000
committerGitHub <noreply@github.com>2023-01-27 20:18:39 +0000
commitb55a8d3ad6bfd031230e654e63ff406facd2976d (patch)
tree5a647c6763b26ea1eef4e1eb36e5e79da408b758 /pkgs/development/tools/ocaml
parent66b3c73fae2a2b127335b2f103edc9c868fadc71 (diff)
parent6043e3af4ec34a42d1f45620527eb3081e5b564a (diff)
downloadnixpkgs-b55a8d3ad6bfd031230e654e63ff406facd2976d.tar
nixpkgs-b55a8d3ad6bfd031230e654e63ff406facd2976d.tar.gz
nixpkgs-b55a8d3ad6bfd031230e654e63ff406facd2976d.tar.bz2
nixpkgs-b55a8d3ad6bfd031230e654e63ff406facd2976d.tar.lz
nixpkgs-b55a8d3ad6bfd031230e654e63ff406facd2976d.tar.xz
nixpkgs-b55a8d3ad6bfd031230e654e63ff406facd2976d.tar.zst
nixpkgs-b55a8d3ad6bfd031230e654e63ff406facd2976d.zip
Merge pull request #205646 from symphorien/ocamlconflict
ocamlPackages.findlib: detect conflicts of version early
Diffstat (limited to 'pkgs/development/tools/ocaml')
-rw-r--r--pkgs/development/tools/ocaml/findlib/default.nix13
1 files changed, 13 insertions, 0 deletions
diff --git a/pkgs/development/tools/ocaml/findlib/default.nix b/pkgs/development/tools/ocaml/findlib/default.nix
index 51df81cea5e..f48ce5abf3f 100644
--- a/pkgs/development/tools/ocaml/findlib/default.nix
+++ b/pkgs/development/tools/ocaml/findlib/default.nix
@@ -44,6 +44,15 @@ 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
@@ -51,6 +60,10 @@ stdenv.mkDerivation rec {
     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 = {