Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 40 additions & 39 deletions pkgs/os-specific/linux/ffado/default.nix
Original file line number Diff line number Diff line change
@@ -1,44 +1,52 @@
{ stdenv, fetchurl, scons, pkgconfig, which, makeWrapper, python
, expat, libraw1394, libconfig, libavc1394, libiec61883, libxmlxx, glibmm
, expat, libraw1394, libconfig, libavc1394, libiec61883, libxmlxx
, alsaLib, dbus, dbus_cplusplus

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

# Other Flags
, prefix ? ""
, pyqt4 ? null, dbus-python ? null

# ffado contain two (actually) independed packages core libraries and mixer,
# each of them have completely independed set of dependencies, and mixer even
# not use libraries for core packages. So `mixerOnly` parameter change logic of
# these expression, patching out all-but-mixer. Otherwise we have perfect build loop
# (via ffado -> pyqt4 -> qt4 -> pulseaudio -> ffado)
, mixerOnly ? false
}:

let

shouldUsePkg = pkg: if pkg != null && pkg.meta.available then pkg else null;

libOnly = prefix == "lib";

optLibjack2 = shouldUsePkg libjack2;
optDbus = shouldUsePkg dbus;
optDbus_cplusplus = shouldUsePkg dbus_cplusplus;
optAlsaLib = shouldUsePkg alsaLib;
optPyqt4 = shouldUsePkg pyqt4;
optPythonDBus = shouldUsePkg dbus-python;
optXdg_utils = shouldUsePkg xdg_utils;
PYDIR="$out/lib/${python.libPrefix}/site-packages";
BINDIR = if mixerOnly then "$out/bin" else "$bin/bin";
SCONS_OPTIONS = ''
PREFIX=$out \
PYPKGDIR=${PYDIR} \
DEBUG=False \
ENABLE_ALL=True \
SERIALIZE_USE_EXPAT=True \
BUILD_TESTS=False \
UDEVDIR=$out/lib/udev/rules.d \
BINDIR=${BINDIR} \
INCLUDEDIR=$dev/include \
WILL_DEAL_WITH_XDG_MYSELF=True \
BUILD_MIXER=${if mixerOnly then "True" else "False"} \
'';
in
stdenv.mkDerivation rec {
name = "${prefix}ffado-${version}";
name = "ffado-${if mixerOnly then "mixer" else "core"}-${version}";
version = "2.4.0";

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

outputs = if mixerOnly then [ "out" ] else [ "out" "bin" "dev" ];

nativeBuildInputs = [ scons pkgconfig which makeWrapper python ];

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

postPatch = ''
Expand All @@ -54,6 +62,9 @@ stdenv.mkDerivation rec {
sed -i -e '1i #include <stdlib.h>' \
-e '1i #include "version.h"' \
src/libutil/serialize_expat.cpp
'' + stdenv.lib.optionalString mixerOnly ''
sed 's!dirs=subdirs!dirs=["support/mixer-qt4"]!' -i SConstruct
sed "/env.Install/ d" -i SConstruct
'';

preConfigure = ''
Expand All @@ -62,25 +73,15 @@ stdenv.mkDerivation rec {

# 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 \
scons ${SCONS_OPTIONS}
'';

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
'' + stdenv.lib.optionalString (optPyqt4 != null && optPythonDBus != null) ''
installPhase = ''
scons ${SCONS_OPTIONS} ${if mixerOnly then "${BINDIR} ${PYDIR}" else "install"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to do this here, but eventually I want to get scons to have setup hook that defines these phases (like is done with cmake, ninja, etc...).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK other legal way to bypass library build, when we build only mixer. scons $out/lib/python $out/bin force installing only needed stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewbauer what can I do, to get this one PR merged? Is a deepest rebuild trigger in my WIP tree at the moment. (probably we can even drop mixer temporary, and make separate package for it, if anyone need it really)

'' + stdenv.lib.optionalString mixerOnly ''
wrapProgram $out/bin/ffado-mixer --prefix PYTHONPATH : \
$PYTHONPATH:$PYDIR:${optPyqt4}/$LIBSUFFIX:${optPythonDBus}/$LIBSUFFIX:

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

meta = with stdenv.lib; {
homepage = http://www.ffado.org;
Expand Down
5 changes: 3 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13372,10 +13372,11 @@ with pkgs;

fatrace = callPackage ../os-specific/linux/fatrace { };

ffado = callPackage ../os-specific/linux/ffado {
ffado = callPackage ../os-specific/linux/ffado { };
ffado-mixer = callPackage ../os-specific/linux/ffado {
inherit (python2Packages) python pyqt4 dbus-python;
mixerOnly = true;
};
libffado = ffado.override { prefix = "lib"; };

fbterm = callPackage ../os-specific/linux/fbterm { };

Expand Down