summary refs log tree commit diff
path: root/pkgs/development/libraries/science/math/or-tools/default.nix
blob: 5294c779a32b3b1215d4ab79f2d80bd759c153c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ stdenv, fetchFromGitHub, cmake, google-gflags, which
, lsb-release, glog, protobuf, cbc, zlib }:

stdenv.mkDerivation rec {
  name = "or-tools-${version}";
  version = "v6.9.1";

  src = fetchFromGitHub {
    owner = "google";
    repo = "or-tools";
    rev = version;
    sha256 = "099j1mc7vvry0a2fiz9zvk6divivglzphv48wbw0c6nd5w8hb27c";
  };

  # The original build system uses cmake which does things like pull
  # in dependencies through git and Makefile creation time. We
  # obviously don't want to do this so instead we provide the
  # dependencies straight from nixpkgs and use the make build method.
  configurePhase = ''
    cat <<EOF > Makefile.local
    UNIX_GFLAGS_DIR=${google-gflags}
    UNIX_GLOG_DIR=${glog}
    UNIX_PROTOBUF_DIR=${protobuf}
    UNIX_CBC_DIR=${cbc}
    EOF
  '';

  buildPhase = ''
    make cc
  '';

  installPhase = ''
    make install_cc prefix=$out
  '';

  patches = [
    # In "expected" way of compilation, the glog package is compiled
    # with gflags support which then makes gflags header transitively
    # included through glog. However in nixpkgs we don't compile glog
    # with gflags so we have to include it ourselves. Upstream should
    # always include gflags to support both ways I think.
    #
    # Upstream ticket: https://github.com/google/or-tools/issues/902
    ./gflags-include.patch
  ];

  nativeBuildInputs = [
    cmake lsb-release which zlib
  ];
  propagatedBuildInputs = [
    google-gflags glog protobuf cbc
  ];

  meta = with stdenv.lib; {
    homepage = https://github.com/google/or-tools;
    license = licenses.asl20;
    description = ''
      Google's software suite for combinatorial optimization.
    '';
    maintainers = with maintainers; [ fuuzetsu ];
    platforms = with platforms; linux;
  };
}