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

# tests
, ffmpeg-headless
}:

stdenv.mkDerivation rec {
  pname = "libopus";
  version = "1.4";

  src = fetchurl {
    url = "https://downloads.xiph.org/releases/opus/opus-${version}.tar.gz";
    sha256 = "sha256-ybMrQlO+WuY9H/Fu6ga5S18PKVG3oCrO71jjo85JxR8=";
  };

  patches = [
    ./fix-pkg-config-paths.patch
    # Some tests time out easily on slower machines
    ./test-timeout.patch
    # Fix meson build for arm64. Remove with next release
    # https://gitlab.xiph.org/xiph/opus/-/merge_requests/59
    (fetchpatch {
      url = "https://gitlab.xiph.org/xiph/opus/-/commit/20c032d27c59d65b19b8ffbb2608e5282fe817eb.patch";
      hash = "sha256-2pX+0ay5PTyHL2plameBX2L1Q4aTx7V7RGiTdhNIuE4=";
    })
  ];

  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.tests = {
    inherit ffmpeg-headless;
  };

  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${version}";
    license = licenses.bsd3;
    platforms = platforms.all;
    maintainers = [ ];
  };
}