summary refs log tree commit diff
path: root/pkgs/development/libraries/gaia/default.nix
blob: d35feb62158a3483e73b166eb17afe1988f59519 (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
{ stdenv
, lib
, fetchFromGitHub
, libyaml
, swig
, pkgconfig
, wafHook
, makeWrapper
, qt4
, python
, pythonSupport ? true
# Default to false since it brakes the build
, stlfacadeSupport ? false
, assertsSupport ? true
, cyclopsSupport ? true
}:

assert pythonSupport -> python != null;

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

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

  # 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"
  '';

  # This is not exactly specified in upstream's README but it's needed by the
  # resultings $out/bin/gaiafusion script
  pythonEnv = (if pythonSupport then
    python.withPackages(ps: with ps; [
      pyyaml
    ])
  else null);

  nativeBuildInputs = [
    wafHook
    pkgconfig
    swig
    makeWrapper
  ];
  buildInputs = [
    libyaml
    qt4
  ]
    ++ lib.optionals (pythonSupport) [
      pythonEnv
    ]
  ;
  wafConfigureFlags = [
  ]
    ++ lib.optionals (pythonSupport) [ "--with-python-bindings" ]
    ++ lib.optionals (stlfacadeSupport) [ "--with-stlfacade" ]
    ++ lib.optionals (assertsSupport) [ "--with-asserts" ]
    ++ lib.optionals (cyclopsSupport) [ "--with-cyclops" ]
  ;
  # only gaiafusion is a python executable that needs patchShebangs
  postInstall = (if pythonSupport then ''
    # We can't use patchShebangs because it will use bare bones $python/bin/python
    # and we need a python environment with pyyaml
    wrapProgram $out/bin/gaiafusion --prefix PYTHONPATH : $out/${python.sitePackages}:${pythonEnv}/${python.sitePackages}
  '' else "");

  meta = with lib; {
    homepage = "https://github.com/MTG/gaia";
    description = "C++ library with python bindings which implements similarity measures and classifications on the results of audio analysis, and generates classification models that Essentia can use to compute high-level description of music";
    maintainers = with maintainers; [ doronbehar ];
    license = licenses.agpl3;
  };
}