Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 150 lines 3.4 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchurl, 6 ocaml, 7 findlib, 8 ocamlbuild, 9 ocaml_oasis, 10 bitstring, 11 camlzip, 12 cmdliner, 13 core_kernel, 14 ezjsonm, 15 fileutils, 16 mmap, 17 lwt, 18 ocamlgraph, 19 ocurl, 20 re, 21 uri, 22 zarith, 23 piqi, 24 piqi-ocaml, 25 uuidm, 26 llvm, 27 frontc, 28 ounit, 29 ppx_jane, 30 parsexp, 31 utop, 32 libxml2, 33 ncurses, 34 linenoise, 35 ppx_bap, 36 ppx_bitstring, 37 yojson, 38 which, 39 makeWrapper, 40 writeText, 41 z3, 42}: 43 44if lib.versionOlder ocaml.version "4.08" then 45 throw "BAP is not available for OCaml ${ocaml.version}" 46else 47 48 stdenv.mkDerivation rec { 49 pname = "ocaml${ocaml.version}-bap"; 50 version = "2.5.0"; 51 src = fetchFromGitHub { 52 owner = "BinaryAnalysisPlatform"; 53 repo = "bap"; 54 rev = "v${version}"; 55 sha256 = "1c30zxn0zyi0wypvjmik3fd6n6a8xjcb102qfnccn1af052bvsrd"; 56 }; 57 58 sigs = fetchurl { 59 url = "https://github.com/BinaryAnalysisPlatform/bap/releases/download/v${version}/sigs.zip"; 60 sha256 = "0d69jd28z4g64mglq94kj5imhmk5f6sgcsh9q2nij3b0arpcliwk"; 61 }; 62 63 createFindlibDestdir = true; 64 65 setupHook = writeText "setupHook.sh" '' 66 export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/ocaml${ocaml.version}-bap-${version}/" 67 export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/ocaml${ocaml.version}-bap-${version}-llvm-plugins/" 68 ''; 69 70 nativeBuildInputs = [ 71 which 72 makeWrapper 73 ocaml 74 findlib 75 ocamlbuild 76 ocaml_oasis 77 ]; 78 79 buildInputs = [ 80 ocamlbuild 81 linenoise 82 ounit 83 ppx_bitstring 84 z3 85 utop 86 libxml2 87 ncurses 88 ]; 89 90 propagatedBuildInputs = [ 91 bitstring 92 camlzip 93 cmdliner 94 ppx_bap 95 core_kernel 96 ezjsonm 97 fileutils 98 mmap 99 lwt 100 ocamlgraph 101 ocurl 102 re 103 uri 104 zarith 105 piqi 106 parsexp 107 piqi-ocaml 108 uuidm 109 frontc 110 yojson 111 ]; 112 113 installPhase = '' 114 runHook preInstall 115 export OCAMLPATH=$OCAMLPATH:$OCAMLFIND_DESTDIR; 116 export PATH=$PATH:$out/bin 117 export CAML_LD_LIBRARY_PATH=''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}$OCAMLFIND_DESTDIR/bap-plugin-llvm/:$OCAMLFIND_DESTDIR/bap/ 118 mkdir -p $out/lib/bap 119 make install 120 rm $out/bin/baptop 121 makeWrapper ${utop}/bin/utop $out/bin/baptop --prefix OCAMLPATH : $OCAMLPATH --prefix PATH : $PATH --add-flags "-ppx ppx-bap -short-paths -require \"bap.top\"" 122 wrapProgram $out/bin/bapbuild --prefix OCAMLPATH : $OCAMLPATH --prefix PATH : $PATH 123 ln -s $sigs $out/share/bap/sigs.zip 124 runHook postInstall 125 ''; 126 127 disableIda = "--disable-ida"; 128 disableGhidra = "--disable-ghidra"; 129 130 patches = [ 131 ./curses_is_ncurses.patch 132 ]; 133 134 preConfigure = '' 135 substituteInPlace oasis/elf-loader --replace bitstring.ppx ppx_bitstring 136 ''; 137 138 configureFlags = [ 139 "--enable-everything ${disableIda} ${disableGhidra}" 140 "--with-llvm-config=${llvm.dev}/bin/llvm-config" 141 ]; 142 143 meta = with lib; { 144 description = "Platform for binary analysis. It is written in OCaml, but can be used from other languages"; 145 homepage = "https://github.com/BinaryAnalysisPlatform/bap/"; 146 license = licenses.mit; 147 maintainers = [ maintainers.maurer ]; 148 mainProgram = "bap"; 149 }; 150 }