1{ lib
2, stdenv
3, fetchpatch
4, fetchurl
5, gitUpdater
6, meson
7, python3
8, ninja
9, fixedPoint ? false
10, withCustomModes ? true
11, withIntrinsics ? stdenv.hostPlatform.isAarch || stdenv.hostPlatform.isx86
12, withAsm ? false
13
14# tests
15, ffmpeg-headless
16, testers
17}:
18
19stdenv.mkDerivation (finalAttrs: {
20 pname = "libopus";
21 version = "1.5.2";
22
23 src = fetchurl {
24 url = "https://downloads.xiph.org/releases/opus/opus-${finalAttrs.version}.tar.gz";
25 hash = "sha256-ZcHS94ufL7IAgsOMvkfJUa1YOTRYduRpQWEu6H+afOE=";
26 };
27
28 patches = [
29 # Some tests time out easily on slower machines
30 ./test-timeout.patch
31 ];
32
33 postPatch = ''
34 patchShebangs meson/
35 '';
36
37 outputs = [ "out" "dev" ];
38
39 nativeBuildInputs = [
40 meson
41 python3
42 ninja
43 ];
44
45 mesonFlags = [
46 (lib.mesonBool "fixed-point" fixedPoint)
47 (lib.mesonBool "custom-modes" withCustomModes)
48 (lib.mesonEnable "intrinsics" withIntrinsics)
49 (lib.mesonEnable "rtcd" (withIntrinsics || withAsm))
50 (lib.mesonEnable "asm" withAsm)
51 (lib.mesonEnable "docs" false)
52 ];
53
54 doCheck = !stdenv.isi686 && !stdenv.isAarch32; # test_unit_LPC_inv_pred_gain fails
55
56 passthru = {
57 updateScript = gitUpdater {
58 url = "https://gitlab.xiph.org/xiph/opus.git";
59 rev-prefix = "v";
60 };
61
62 tests = {
63 inherit ffmpeg-headless;
64
65 pkg-config = testers.hasPkgConfigModules {
66 package = finalAttrs.finalPackage;
67 moduleNames = [ "opus" ];
68 };
69 };
70 };
71
72 meta = with lib; {
73 description = "Open, royalty-free, highly versatile audio codec";
74 homepage = "https://opus-codec.org/";
75 changelog = "https://gitlab.xiph.org/xiph/opus/-/releases/v${finalAttrs.version}";
76 license = licenses.bsd3;
77 platforms = platforms.all;
78 maintainers = [ ];
79 };
80})