about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/ffado/default.nix
blob: 47112a26c203a19c7d1599efe1a86268a488aa95 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{
  lib,
  stdenv,
  mkDerivation,
  argp-standalone,
  dbus,
  dbus_cplusplus,
  desktop-file-utils,
  fetchurl,
  fetchpatch,
  glibmm,
  libavc1394,
  libconfig,
  libiec61883,
  libraw1394,
  libxmlxx3,
  pkg-config,
  python311,
  scons,
  which,
  wrapQtAppsHook,
}:

let
  python = python311.withPackages (
    pkgs: with pkgs; [
      pyqt5
      dbus-python
    ]
  );
in
mkDerivation rec {
  pname = "ffado";
  version = "2.4.8";

  outputs = [
    "out"
    "bin"
    "dev"
  ];

  src = fetchurl {
    url = "http://www.ffado.org/files/libffado-${version}.tgz";
    hash = "sha256-0iFXYyGctOoHCdc232Ud80/wV81tiS7ItiS0uLKyq2Y=";
  };

  prePatch = ''
    substituteInPlace ./support/tools/ffado-diag.in \
      --replace /lib/modules/ "/run/booted-system/kernel-modules/lib/modules/"
  '';

  patches = [
    # fix installing metainfo file
    ./fix-build.patch

    (fetchpatch {
      name = "musl.patch";
      url = "http://subversion.ffado.org/changeset?format=diff&new=2846&old=2845";
      stripLen = 2;
      hash = "sha256-iWeYnb5J69Uvo1lftc7MWg7WrLa+CGZyOwJPOe8/PKg=";
    })
  ];

  nativeBuildInputs = [
    desktop-file-utils
    (scons.override { python3 = python311; })
    pkg-config
    which
    python
    python.pkgs.pyqt5
    wrapQtAppsHook
  ];

  prefixKey = "PREFIX=";
  sconsFlags = [
    "DEBUG=False"
    "ENABLE_ALL=True"
    "BUILD_TESTS=True"
    "WILL_DEAL_WITH_XDG_MYSELF=True"
    "BUILD_MIXER=True"
    "UDEVDIR=${placeholder "out"}/lib/udev/rules.d"
    "PYPKGDIR=${placeholder "out"}/${python.sitePackages}"
    "BINDIR=${placeholder "bin"}/bin"
    "INCLUDEDIR=${placeholder "dev"}/include"
    "PYTHON_INTERPRETER=${python.interpreter}"
  ];

  buildInputs = [
    dbus
    dbus_cplusplus
    glibmm
    libavc1394
    libconfig
    libiec61883
    libraw1394
    libxmlxx3
    python
  ] ++ lib.optionals (!stdenv.hostPlatform.isGnu) [
    argp-standalone
  ];

  NIX_LDFLAGS = lib.optionalString (!stdenv.hostPlatform.isGnu) "-largp";

  enableParallelBuilding = true;
  dontWrapQtApps = true;

  postInstall = ''
    desktop="$bin/share/applications/ffado-mixer.desktop"
    install -DT -m 444 support/xdg/ffado.org-ffadomixer.desktop $desktop
    substituteInPlace "$desktop" \
      --replace Exec=ffado-mixer "Exec=$bin/bin/ffado-mixer" \
      --replace hi64-apps-ffado ffado-mixer
    install -DT -m 444 support/xdg/hi64-apps-ffado.png "$bin/share/icons/hicolor/64x64/apps/ffado-mixer.png"

    # prevent build tools from leaking into closure
    echo 'See `nix-store --query --tree ${placeholder "out"}`.' > $out/lib/libffado/static_info.txt
  '';

  preFixup = ''
    wrapQtApp $bin/bin/ffado-mixer
  '';

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