about summary refs log tree commit diff
path: root/pkgs/development/libraries/libopus/default.nix
blob: d247b8b0efa6c9ee351dc643f2206de59ef43167 (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
{ lib
, stdenv
, fetchpatch
, fetchurl
, gitUpdater
, meson
, python3
, ninja
, fixedPoint ? false
, withCustomModes ? true
, withIntrinsics ? stdenv.hostPlatform.isAarch || stdenv.hostPlatform.isx86
, withAsm ? false

# tests
, ffmpeg-headless
, testers
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "libopus";
  version = "1.5.2";

  src = fetchurl {
    url = "https://downloads.xiph.org/releases/opus/opus-${finalAttrs.version}.tar.gz";
    hash = "sha256-ZcHS94ufL7IAgsOMvkfJUa1YOTRYduRpQWEu6H+afOE=";
  };

  patches = [
    # Some tests time out easily on slower machines
    ./test-timeout.patch
  ];

  postPatch = ''
    patchShebangs meson/
  '';

  outputs = [ "out" "dev" ];

  nativeBuildInputs = [
    meson
    python3
    ninja
  ];

  mesonFlags = [
    (lib.mesonBool "fixed-point" fixedPoint)
    (lib.mesonBool "custom-modes" withCustomModes)
    (lib.mesonEnable "intrinsics" withIntrinsics)
    (lib.mesonEnable "rtcd" (withIntrinsics || withAsm))
    (lib.mesonEnable "asm" withAsm)
    (lib.mesonEnable "docs" false)
  ];

  doCheck = !stdenv.isi686 && !stdenv.isAarch32; # test_unit_LPC_inv_pred_gain fails

  passthru = {
    updateScript = gitUpdater {
      url = "https://gitlab.xiph.org/xiph/opus.git";
      rev-prefix = "v";
    };

    tests = {
      inherit ffmpeg-headless;

      pkg-config = testers.hasPkgConfigModules {
        package = finalAttrs.finalPackage;
        moduleNames = [ "opus" ];
      };
    };
  };

  meta = with lib; {
    description = "Open, royalty-free, highly versatile audio codec";
    homepage = "https://opus-codec.org/";
    changelog = "https://gitlab.xiph.org/xiph/opus/-/releases/v${finalAttrs.version}";
    license = licenses.bsd3;
    platforms = platforms.all;
    maintainers = [ ];
  };
})