base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / bo / boolector / package.nix
blob30e3cf5002114c247abf7aed2fdf6b72b0aa0b7e
1 { stdenv, fetchFromGitHub, lib, python3, fetchpatch
2 , cmake, lingeling, btor2tools, gtest, gmp
3 }:
5 stdenv.mkDerivation rec {
6   pname = "boolector";
7   version = "3.2.3";
9   src = fetchFromGitHub {
10     owner  = "boolector";
11     repo   = "boolector";
12     rev    = version;
13     hash   = "sha256-CdfpXUbU1+yEmrNyl+hvHlJfpzzzx356naim6vRafDg=";
14   };
16   patches = [
17     # present in master - remove after 3.2.3
18     (fetchpatch {
19       name = "update-unit-tests-to-cpp-14.patch";
20       url = "https://github.com/Boolector/boolector/commit/cc13f371c0c5093d98638ddd213dc835ef3aadf3.patch";
21       hash = "sha256-h8DBhAvUu+wXBwmvwRhHnJv3XrbEpBpvX9D1FI/+avc=";
22     })
23   ];
25   nativeBuildInputs = [ cmake gtest ];
26   buildInputs = [ lingeling btor2tools gmp ];
28   cmakeFlags =
29     [ "-DBUILD_SHARED_LIBS=ON"
30       "-DUSE_LINGELING=YES"
31       "-DBtor2Tools_INCLUDE_DIR=${btor2tools.dev}/include/btor2parser"
32     ] ++ (lib.optional (gmp != null) "-DUSE_GMP=YES");
34   nativeCheckInputs = [ python3 ];
35   doCheck = true;
36   preCheck =
37     let var = if stdenv.hostPlatform.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
38     in
39       # tests modelgen and modelgensmt2 spawn boolector in another processes and
40       # macOS strips DYLD_LIBRARY_PATH, hardcode it for testing
41       lib.optionalString stdenv.hostPlatform.isDarwin ''
42         cp -r bin bin.back
43         install_name_tool -change libboolector.dylib $(pwd)/lib/libboolector.dylib bin/boolector
44       '' + ''
45         export ${var}=$(readlink -f lib)
46         patchShebangs ..
47       '';
49   postCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
50     rm -rf bin
51     mv bin.back bin
52   '';
54   # this is what haskellPackages.boolector expects
55   postInstall = ''
56     cp $out/include/boolector/boolector.h $out/include/boolector.h
57     cp $out/include/boolector/btortypes.h $out/include/btortypes.h
58   '';
60   meta = with lib; {
61     description = "Extremely fast SMT solver for bit-vectors and arrays";
62     homepage    = "https://boolector.github.io";
63     license     = licenses.mit;
64     platforms   = with platforms; linux ++ darwin;
65     maintainers = with maintainers; [ thoughtpolice ];
66   };