about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libopus
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libopus')
-rw-r--r--nixpkgs/pkgs/development/libraries/libopus/default.nix81
-rw-r--r--nixpkgs/pkgs/development/libraries/libopus/fix-pkg-config-paths.patch13
-rw-r--r--nixpkgs/pkgs/development/libraries/libopus/test-timeout.patch9
3 files changed, 103 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libopus/default.nix b/nixpkgs/pkgs/development/libraries/libopus/default.nix
new file mode 100644
index 000000000000..3592c537ac44
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libopus/default.nix
@@ -0,0 +1,81 @@
+{ 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.1";
+
+  src = fetchurl {
+    url = "https://downloads.xiph.org/releases/opus/opus-${finalAttrs.version}.tar.gz";
+    hash = "sha256-uEYQlZuNQXthGqEqIlZeCjcyCXxjidGQmNhEVD40D4U=";
+  };
+
+  patches = [
+    ./fix-pkg-config-paths.patch
+    # 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 = [ ];
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/libopus/fix-pkg-config-paths.patch b/nixpkgs/pkgs/development/libraries/libopus/fix-pkg-config-paths.patch
new file mode 100644
index 000000000000..d54b7f5558c9
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libopus/fix-pkg-config-paths.patch
@@ -0,0 +1,13 @@
+--- i/meson.build
++++ w/meson.build
+@@ -591,8 +591,8 @@ pkgconf = configuration_data()
+ 
+ pkgconf.set('prefix', join_paths(get_option('prefix')))
+ pkgconf.set('exec_prefix', '${prefix}')
+-pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
+-pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
++pkgconf.set('libdir', '${prefix}' / get_option('libdir'))
++pkgconf.set('includedir', '${prefix}' / get_option('includedir'))
+ pkgconf.set('VERSION', opus_version)
+ pkgconf.set('PC_BUILD', pc_build)
+ pkgconf.set('LIBM', libm.found() ? '-lm' : '')
diff --git a/nixpkgs/pkgs/development/libraries/libopus/test-timeout.patch b/nixpkgs/pkgs/development/libraries/libopus/test-timeout.patch
new file mode 100644
index 000000000000..76025e648d8f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libopus/test-timeout.patch
@@ -0,0 +1,9 @@
+--- a/tests/meson.build
++++ b/tests/meson.build
+@@ -1,6 +1,5 @@
+ # Tests that link to libopus
+ opus_tests = [
+-  ['test_opus_api'],
+   ['test_opus_decode', [], 120],
+   ['test_opus_encode', 'opus_encode_regressions.c', 240],
+   ['test_opus_extensions', [], 120],