Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 101 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 [ 44 "all" 45 ] 46 ++ lib.optionals ocaml.nativeCompilers [ 47 "opt" 48 ]; 49 50 setupHook = writeText "setupHook.sh" '' 51 addOCamlPath () { 52 if test -d "''$1/lib/ocaml/${ocaml.version}/site-lib"; then 53 export OCAMLPATH="''${OCAMLPATH-}''${OCAMLPATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/" 54 fi 55 if test -d "''$1/lib/ocaml/${ocaml.version}/site-lib/stublibs"; then 56 export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/stublibs" 57 fi 58 } 59 exportOcamlDestDir () { 60 export OCAMLFIND_DESTDIR="''$out/lib/ocaml/${ocaml.version}/site-lib/" 61 } 62 createOcamlDestDir () { 63 if test -n "''${createFindlibDestdir-}"; then 64 mkdir -p $OCAMLFIND_DESTDIR 65 fi 66 } 67 detectOcamlConflicts () { 68 local conflict 69 conflict="$(ocamlfind list |& grep "has multiple definitions" || true)" 70 if [[ -n "$conflict" ]]; then 71 echo "Conflicting ocaml packages detected"; 72 echo "$conflict" 73 echo "Set dontDetectOcamlConflicts to true to disable this check." 74 exit 1 75 fi 76 } 77 78 # run for every buildInput 79 addEnvHooks "$targetOffset" addOCamlPath 80 # run before installPhase, even without buildInputs, and not in nix-shell 81 preInstallHooks+=(createOcamlDestDir) 82 # run even in nix-shell, and even without buildInputs 83 addEnvHooks "$hostOffset" exportOcamlDestDir 84 # runs after all calls to addOCamlPath 85 if [[ -z "''${dontDetectOcamlConflicts-}" ]]; then 86 postHooks+=("detectOcamlConflicts") 87 fi 88 ''; 89 90 meta = { 91 description = "O'Caml library manager"; 92 homepage = "http://projects.camlcity.org/projects/findlib.html"; 93 license = lib.licenses.mit; 94 maintainers = with lib.maintainers; [ 95 maggesi 96 vbmithr 97 ]; 98 mainProgram = "ocamlfind"; 99 platforms = ocaml.meta.platforms or [ ]; 100 }; 101}