2021-01-17 00:15:33 +00:00
|
|
|
{ lib, stdenv, fetchpatch, fetchFromGitHub, cmake, zlib, gmp, jdk8,
|
2020-04-24 23:36:52 +00:00
|
|
|
# The JDK we use on Darwin currenly makes extensive use of rpaths which are
|
|
|
|
# annoying and break the python library, so let's not bother for now
|
|
|
|
includeJava ? !stdenv.hostPlatform.isDarwin, includeGplCode ? true }:
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
boolToCmake = x: if x then "ON" else "OFF";
|
|
|
|
|
|
|
|
rev = "1.8.0";
|
|
|
|
sha256 = "0q3a8x3iih25xkp2bm842sm2hxlb8hxlls4qmvj7vzwrh4lvsl7b";
|
|
|
|
|
|
|
|
pname = "monosat";
|
|
|
|
version = rev;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "sambayless";
|
|
|
|
repo = pname;
|
|
|
|
inherit rev sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Python 3.8 compatibility
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/sambayless/monosat/commit/a5079711d0df0451f9840f3a41248e56dbb03967.patch";
|
|
|
|
sha256 = "1p2y0jw8hb9c90nbffhn86k1dxd6f6hk5v70dfmpzka3y6g1ksal";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# source behind __linux__ check assumes system is also x86 and
|
|
|
|
# tries to disable x86/x87-specific extended precision mode
|
|
|
|
# https://github.com/sambayless/monosat/issues/33
|
|
|
|
commonPostPatch = lib.optionalString (!stdenv.hostPlatform.isx86) ''
|
|
|
|
substituteInPlace src/monosat/Main.cc \
|
|
|
|
--replace 'defined(__linux__)' '0'
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
core = stdenv.mkDerivation {
|
|
|
|
name = "${pname}-${version}";
|
|
|
|
inherit src patches;
|
2021-12-06 16:07:01 +00:00
|
|
|
postPatch = commonPostPatch;
|
2021-01-15 22:18:51 +00:00
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
buildInputs = [ zlib gmp jdk8 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_STATIC=OFF"
|
|
|
|
"-DJAVA=${boolToCmake includeJava}"
|
|
|
|
"-DGPL=${boolToCmake includeGplCode}"
|
2022-08-12 12:06:08 +00:00
|
|
|
|
|
|
|
# file RPATH_CHANGE could not write new RPATH
|
|
|
|
"-DCMAKE_SKIP_BUILD_RPATH=ON"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postInstall = optionalString includeJava ''
|
|
|
|
mkdir -p $out/share/java
|
|
|
|
cp monosat.jar $out/share/java
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = { inherit python; };
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "SMT solver for Monotonic Theories";
|
|
|
|
platforms = platforms.unix;
|
|
|
|
license = if includeGplCode then licenses.gpl2 else licenses.mit;
|
|
|
|
homepage = "https://github.com/sambayless/monosat";
|
|
|
|
maintainers = [ maintainers.acairncross ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
python = { buildPythonPackage, cython, pytestCheckHook }: buildPythonPackage {
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit pname version src patches;
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ core cython ];
|
|
|
|
|
|
|
|
# This tells setup.py to use cython, which should produce faster bindings
|
|
|
|
MONOSAT_CYTHON = true;
|
|
|
|
|
|
|
|
# After patching src, move to where the actually relevant source is. This could just be made
|
|
|
|
# the sourceRoot if it weren't for the patch.
|
2021-12-06 16:07:01 +00:00
|
|
|
postPatch = commonPostPatch + ''
|
2020-04-24 23:36:52 +00:00
|
|
|
cd src/monosat/api/python
|
|
|
|
'' +
|
|
|
|
# The relative paths here don't make sense for our Nix build
|
|
|
|
# TODO: do we want to just reference the core monosat library rather than copying the
|
|
|
|
# shared lib? The current setup.py copies the .dylib/.so...
|
|
|
|
''
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace 'library_dir = "../../../../"' 'library_dir = "${core}/lib/"'
|
|
|
|
'';
|
2022-05-18 14:49:53 +00:00
|
|
|
|
|
|
|
checkInputs = [ pytestCheckHook ];
|
|
|
|
|
|
|
|
disabledTests = [
|
|
|
|
"test_assertAtMostOne"
|
|
|
|
"test_assertEqual"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
in core
|