Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchFromGitHub
2, cmake
3, pkg-config
4, alsa-lib
5, jack2
6, libpulseaudio
7, sndio
8, speexdsp
9, AudioUnit
10, CoreAudio
11, CoreServices
12, lazyLoad ? !stdenv.isDarwin
13}:
14
15assert lib.assertMsg (stdenv.isDarwin -> !lazyLoad) "cubeb: lazyLoad is inert on Darwin";
16
17let
18 backendLibs = [
19 alsa-lib
20 jack2
21 libpulseaudio
22 sndio
23 ];
24
25in stdenv.mkDerivation {
26 pname = "cubeb";
27 version = "unstable-2022-10-18";
28
29 src = fetchFromGitHub {
30 owner = "mozilla";
31 repo = "cubeb";
32 rev = "27d2a102b0b75d9e49d43bc1ea516233fb87d778";
33 hash = "sha256-q+uz1dGU4LdlPogL1nwCR/KuOX4Oy3HhMdA6aJylBRk=";
34 };
35
36 nativeBuildInputs = [
37 cmake
38 pkg-config
39 ];
40
41 buildInputs = [ speexdsp ] ++ (
42 if stdenv.isDarwin then [ AudioUnit CoreAudio CoreServices ]
43 else backendLibs
44 );
45
46 cmakeFlags = [
47 "-DBUILD_SHARED_LIBS=ON"
48 "-DBUILD_TESTS=OFF" # tests require an audio server
49 "-DBUNDLE_SPEEX=OFF"
50 "-DUSE_SANITIZERS=OFF"
51
52 # Whether to lazily load libraries with dlopen()
53 "-DLAZY_LOAD_LIBS=${if lazyLoad then "ON" else "OFF"}"
54 ];
55
56 passthru = {
57 # For downstream users when lazyLoad is true
58 backendLibs = lib.optionals lazyLoad backendLibs;
59 };
60
61 meta = with lib; {
62 description = "Cross platform audio library";
63 homepage = "https://github.com/mozilla/cubeb";
64 license = licenses.isc;
65 platforms = platforms.linux ++ platforms.darwin;
66 maintainers = with maintainers; [ zhaofengli ];
67 };
68}