summary refs log tree commit diff
path: root/pkgs/os-specific/linux/ffado/default.nix
blob: dcbf0e567ad5b223a301ee80bd3b048b9662f85c (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
90
91
92
93
{ stdenv, fetchurl, scons, pkgconfig, which, makeWrapper, python
, expat, libraw1394, libconfig, libavc1394, libiec61883

# Optional dependencies
, libjack2 ? null, dbus ? null, dbus_cplusplus ? null, alsaLib ? null
, pyqt4 ? null, xdg_utils ? null

, glibmm
, pythonDBus, qt4

# Other Flags
, prefix ? ""
}:

let

  shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;

  libOnly = prefix == "lib";

  optLibjack2 = shouldUsePkg libjack2;
  optDbus = shouldUsePkg dbus;
  optDbus_cplusplus = shouldUsePkg dbus_cplusplus;
  optAlsaLib = shouldUsePkg alsaLib;
  optPyqt4 = shouldUsePkg pyqt4;
  optXdg_utils = shouldUsePkg xdg_utils;
in
stdenv.mkDerivation rec {
  name = "${prefix}ffado-${version}";
  version = "2.2.1";

  src = fetchurl {
    url = "http://www.ffado.org/files/libffado-${version}.tgz";
    sha256 = "1ximic90l0av91njb123ra2zp6mg23yg5iz8xa5371cqrn79nacz";
  };

  nativeBuildInputs = [ scons pkgconfig which makeWrapper python ];

  buildInputs = [
    expat libraw1394 libconfig libavc1394 libiec61883
  ] ++ stdenv.lib.optionals (!libOnly) [
    optLibjack2 optDbus optDbus_cplusplus optAlsaLib optPyqt4
    optXdg_utils
    # dbus dbus_cplusplus glibmm
    # pyqt4
    # python pythonDBus qt4
  ];

  patches = [ ./build-fix.patch ];

  postPatch = ''
    # SConstruct checks cpuinfo and an objdump of /bin/mount to determine the appropriate arch
    # Let's just skip this and tell it which to build
    sed '/def is_userspace_32bit(cpuinfo):/a\
        return ${if stdenv.is64bit then "False" else "True"}' -i SConstruct

    # Lots of code is missing random headers to exist
    sed -i '1i #include <memory>' \
      src/ffadodevice.h src/bebob/bebob_dl_mgr.cpp tests/scan-devreg.cpp
    sed -i -e '1i #include <stdlib.h>' \
      -e '1i #include "version.h"' \
      src/libutil/serialize_expat.cpp
  '';

  # TODO fix ffado-diag, it doesn't seem to use PYPKGDIR
  buildPhase = ''
    export PYDIR=$out/lib/${python.libPrefix}/site-packages

    scons PYPKGDIR=$PYDIR DEBUG=False \
      ENABLE_ALL=True \
      SERIALIZE_USE_EXPAT=True \
  '';

  installPhase = if libOnly then ''
    scons PREFIX=$TMPDIR UDEVDIR=$TMPDIR \
      LIBDIR=$out/lib INCLUDEDIR=$out/include install
  '' else ''
    scons PREFIX=$out PYPKGDIR=$PYDIR UDEVDIR=$out/lib/udev/rules.d install

    wrapProgram $out/bin/ffado-mixer --prefix PYTHONPATH : \
      $PYTHONPATH:$PYDIR:${pyqt4}/$LIBSUFFIX:${pythonDBus}/$LIBSUFFIX:
    wrapProgram $out/bin/ffado-diag --prefix PYTHONPATH : \
      $PYTHONPATH:$PYDIR:$out/share/libffado/python:${pyqt4}/$LIBSUFFIX:${pythonDBus}/$LIBSUFFIX:
  '';

  meta = with stdenv.lib; {
    homepage = http://www.ffado.org;
    description = "FireWire audio drivers";
    license = licenses.gpl3;
    maintainers = with maintainers; [ goibhniu wkennington ];
    platforms = platforms.linux;
  };
}