at master 100 lines 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 ncurses, 6 ocaml, 7 writeText, 8}: 9 10stdenv.mkDerivation rec { 11 pname = "ocaml${ocaml.version}-findlib"; 12 version = "1.9.8"; 13 14 src = fetchurl { 15 url = "http://download.camlcity.org/download/findlib-${version}.tar.gz"; 16 hash = "sha256-ZiyRD3dOn+46GcTgV/OAWBqy/E7lLaR2EwSsnDG4hp0="; 17 }; 18 19 nativeBuildInputs = [ ocaml ]; 20 buildInputs = lib.optional (lib.versionOlder ocaml.version "4.07") ncurses; 21 22 patches = [ 23 ./ldconf.patch 24 ./install_topfind.patch 25 ]; 26 27 dontAddPrefix = true; 28 dontAddStaticConfigureFlags = true; 29 configurePlatforms = [ ]; 30 31 configureFlags = [ 32 "-bindir" 33 "${placeholder "out"}/bin" 34 "-mandir" 35 "${placeholder "out"}/share/man" 36 "-sitelib" 37 "${placeholder "out"}/lib/ocaml/${ocaml.version}/site-lib" 38 "-config" 39 "${placeholder "out"}/etc/findlib.conf" 40 ]; 41 42 buildFlags = [ 43 "all" 44 ] 45 ++ lib.optionals ocaml.nativeCompilers [ 46 "opt" 47 ]; 48 49 setupHook = writeText "setupHook.sh" '' 50 addOCamlPath () { 51 if test -d "''$1/lib/ocaml/${ocaml.version}/site-lib"; then 52 export OCAMLPATH="''${OCAMLPATH-}''${OCAMLPATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/" 53 fi 54 if test -d "''$1/lib/ocaml/${ocaml.version}/site-lib/stublibs"; then 55 export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/stublibs" 56 fi 57 } 58 exportOcamlDestDir () { 59 export OCAMLFIND_DESTDIR="''$out/lib/ocaml/${ocaml.version}/site-lib/" 60 } 61 createOcamlDestDir () { 62 if test -n "''${createFindlibDestdir-}"; then 63 mkdir -p $OCAMLFIND_DESTDIR 64 fi 65 } 66 detectOcamlConflicts () { 67 local conflict 68 conflict="$(ocamlfind list |& grep "has multiple definitions" || true)" 69 if [[ -n "$conflict" ]]; then 70 echo "Conflicting ocaml packages detected"; 71 echo "$conflict" 72 echo "Set dontDetectOcamlConflicts to true to disable this check." 73 exit 1 74 fi 75 } 76 77 # run for every buildInput 78 addEnvHooks "$targetOffset" addOCamlPath 79 # run before installPhase, even without buildInputs, and not in nix-shell 80 preInstallHooks+=(createOcamlDestDir) 81 # run even in nix-shell, and even without buildInputs 82 addEnvHooks "$hostOffset" exportOcamlDestDir 83 # runs after all calls to addOCamlPath 84 if [[ -z "''${dontDetectOcamlConflicts-}" ]]; then 85 postHooks+=("detectOcamlConflicts") 86 fi 87 ''; 88 89 meta = { 90 description = "O'Caml library manager"; 91 homepage = "http://projects.camlcity.org/projects/findlib.html"; 92 license = lib.licenses.mit; 93 maintainers = with lib.maintainers; [ 94 maggesi 95 vbmithr 96 ]; 97 mainProgram = "ocamlfind"; 98 platforms = ocaml.meta.platforms or [ ]; 99 }; 100}