1{
2 lib,
3 stdenv,
4 argp-standalone,
5 dbus,
6 dbus_cplusplus,
7 fetchurl,
8 glibmm,
9 libavc1394,
10 libconfig,
11 libiec61883,
12 libraw1394,
13 libxmlxx3,
14 pkg-config,
15 python3,
16 scons,
17 which,
18 withMixer ? false,
19 qt5,
20 udevCheckHook,
21}:
22
23let
24 python = python3.withPackages (
25 pkgs:
26 with pkgs;
27 (
28 [
29 distutils
30 ]
31 ++ lib.optionals withMixer [
32 pyqt5
33 dbus-python
34 ]
35 )
36 );
37in
38stdenv.mkDerivation rec {
39 pname = "ffado";
40 version = "2.4.9";
41
42 outputs = [
43 "out"
44 "bin"
45 "dev"
46 ];
47
48 src = fetchurl {
49 url = "http://www.ffado.org/files/libffado-${version}.tgz";
50 hash = "sha256-xELFL60Ryv1VE7tOhGyFHxAchIT4karFRe0ZDo/U0Q8=";
51 };
52
53 prePatch = ''
54 substituteInPlace ./support/tools/ffado-diag.in \
55 --replace /lib/modules/ "/run/booted-system/kernel-modules/lib/modules/"
56
57 # prevent build tools from leaking into closure
58 substituteInPlace support/tools/SConscript --replace-fail \
59 'support/tools/ffado-diag --static' \
60 "echo '"'See `nix-store --query --tree ${placeholder "out"}`.'"'"
61 ''
62 + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
63 # skip the CC sanity check, since that requires invoking cross-compiled binaries during build
64 substituteInPlace SConstruct \
65 --replace-fail 'conf.CompilerCheck()' 'True' \
66 --replace-fail "pkg-config" "$PKG_CONFIG"
67 substituteInPlace admin/pkgconfig.py \
68 --replace-fail "pkg-config" "$PKG_CONFIG"
69 '';
70
71 nativeBuildInputs = [
72 scons
73 pkg-config
74 which
75 udevCheckHook
76 ]
77 ++ lib.optionals withMixer [
78 python
79 python.pkgs.pyqt5
80 qt5.wrapQtAppsHook
81 ];
82
83 prefixKey = "PREFIX=";
84 sconsFlags = [
85 "CUSTOM_ENV=True" # tell SConstruct to use nixpkgs' CC/CXX/CFLAGS
86 "DETECT_USERSPACE_ENV=False"
87 "DEBUG=False"
88 "ENABLE_ALL=True"
89 "BUILD_TESTS=True"
90 "BUILD_MIXER=${if withMixer then "True" else "False"}"
91 "UDEVDIR=${placeholder "out"}/lib/udev/rules.d"
92 "PYPKGDIR=${placeholder "out"}/${python.sitePackages}"
93 "BINDIR=${placeholder "bin"}/bin"
94 "INCLUDEDIR=${placeholder "dev"}/include"
95 "PYTHON_INTERPRETER=${python.interpreter}"
96 ];
97
98 buildInputs = [
99 dbus
100 dbus_cplusplus
101 glibmm
102 libavc1394
103 libconfig
104 libiec61883
105 libraw1394
106 libxmlxx3
107 python
108 ]
109 ++ lib.optionals (!stdenv.hostPlatform.isGnu) [
110 argp-standalone
111 ];
112
113 NIX_LDFLAGS = lib.optionalString (!stdenv.hostPlatform.isGnu) "-largp";
114
115 enableParallelBuilding = true;
116 dontWrapQtApps = true;
117 strictDeps = true;
118 doInstallCheck = true;
119
120 preFixup = lib.optionalString withMixer ''
121 wrapQtApp "$bin/bin/ffado-mixer"
122 '';
123
124 meta = with lib; {
125 homepage = "http://www.ffado.org";
126 description = "FireWire audio drivers";
127 license = licenses.gpl3;
128 maintainers = with maintainers; [
129 michojel
130 ];
131 platforms = platforms.linux;
132 };
133}