summary refs log tree commit diff
path: root/pkgs/development/libraries/gaia/default.nix
blob: 46ed3626d2af1cf8943da3d9cf91444e4602d76b (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{ stdenv
, lib
, fetchFromGitHub
, libyaml
, swig
, eigen
, pkgconfig
, python2
, wafHook
, makeWrapper
, qt4
, pythonPackages
, pythonSupport ? false
# Default to false since it breaks the build, see https://github.com/MTG/gaia/issues/11
, stlfacadeSupport ? false
, assertsSupport ? true
, cyclopsSupport ? true
}:

assert pythonSupport -> pythonPackages != null;

stdenv.mkDerivation rec {
  pname = "gaia";
  version = "2.4.6";

  src = fetchFromGitHub {
    owner = "MTG";
    repo = "gaia";
    rev = "v${version}";
    sha256 = "03vmdq7ca4f7zp2f4sxyqa8sdpdma3mn9fz4z7d93qryl0bhi7z3";
  };

  # Fix installation error when waf tries to put files in /etc/
  prePatch = ''
  '' + lib.optionalString cyclopsSupport ''
    substituteInPlace src/wscript \
      --replace "/etc/cyclops" "$out/etc/cyclops" \
      --replace "/etc/init.d" "$out/etc/init.d"
  '';

  nativeBuildInputs = [
    pkgconfig
    python2 # For wafHook
    swig
    wafHook
  ]
    # The gaiafusion binary inside $out/bin needs a shebangs patch, and
    # wrapping with the appropriate $PYTHONPATH
    ++ lib.optionals (pythonSupport) [
      pythonPackages.wrapPython
    ]
  ;

  buildInputs = [
    libyaml
    eigen
    qt4
  ];

  propagatedBuildInputs = []
    ++ lib.optionals (pythonSupport) [
      # This is not exactly specified in upstream's README but it's needed by the
      # resulting $out/bin/gaiafusion script
      pythonPackages.pyyaml
    ]
  ;

  wafConfigureFlags = []
    ++ lib.optionals (pythonSupport) [ "--with-python-bindings" ]
    ++ lib.optionals (stlfacadeSupport) [ "--with-stlfacade" ]
    ++ lib.optionals (assertsSupport) [ "--with-asserts" ]
    ++ lib.optionals (cyclopsSupport) [ "--with-cyclops" ]
  ;

  postFixup = ''
  ''
    + lib.optionalString pythonSupport ''
      wrapPythonPrograms
    ''
  ;

  meta = with lib; {
    homepage = "https://github.com/MTG/gaia";
    description = "General library to work with points in a semimetric space";
    maintainers = with maintainers; [ doronbehar ];
    platforms = platforms.x86; # upstream assume SSE2 / fails on ARM
    license = licenses.agpl3;
  };
}