@@ -0,0 +1,63 @@
1+{ stdenv, fetchFromGitHub, cmake, google-gflags, which
2+, lsb-release, glog, protobuf, cbc, zlib }:
3+
4+stdenv.mkDerivation rec {
5+ name = "or-tools-${version}";
6+ version = "v6.9.1";
7+
8+ src = fetchFromGitHub {
9+ owner = "google";
10+ repo = "or-tools";
11+ rev = version;
12+ sha256 = "099j1mc7vvry0a2fiz9zvk6divivglzphv48wbw0c6nd5w8hb27c";
13+ };
14+
15+ # The original build system uses cmake which does things like pull
16+ # in dependencies through git and Makefile creation time. We
17+ # obviously don't want to do this so instead we provide the
18+ # dependencies straight from nixpkgs and use the make build method.
19+ configurePhase = ''
20+ cat <<EOF > Makefile.local
21+ UNIX_GFLAGS_DIR=${google-gflags}
22+ UNIX_GLOG_DIR=${glog}
23+ UNIX_PROTOBUF_DIR=${protobuf}
24+ UNIX_CBC_DIR=${cbc}
25+ EOF
26+ '';
27+
28+ buildPhase = ''
29+ make cc
30+ '';
31+
32+ installPhase = ''
33+ make install_cc prefix=$out
34+ '';
35+
36+ patches = [
37+ # In "expected" way of compilation, the glog package is compiled
38+ # with gflags support which then makes gflags header transitively
39+ # included through glog. However in nixpkgs we don't compile glog
40+ # with gflags so we have to include it ourselves. Upstream should
41+ # always include gflags to support both ways I think.
42+ #
43+ # Upstream ticket: https://github.com/google/or-tools/issues/902
44+ ./gflags-include.patch
45+ ];
46+
47+ nativeBuildInputs = [
48+ cmake lsb-release which zlib
49+ ];
50+ propagatedBuildInputs = [
51+ google-gflags glog protobuf cbc
52+ ];
53+
54+ meta = with stdenv.lib; {
55+ homepage = https://github.com/google/or-tools;
56+ license = licenses.asl20;
57+ description = ''
58+ Google's software suite for combinatorial optimization.
59+ '';
60+ maintainers = with maintainers; [ fuuzetsu ];
61+ platforms = with platforms; linux;
62+ };
63+}