nixpkgs/pkgs/applications/networking/pjsip/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

134 lines
4.0 KiB
Nix
Raw Normal View History

{ lib
, testers
, stdenv
, fetchFromGitHub
, fetchpatch
, openssl
, libsamplerate
2023-02-01 14:38:11 +00:00
, swig
, alsa-lib
, AppKit
, CoreFoundation
, Security
2023-02-01 14:38:11 +00:00
, python3
, pythonSupport ? true
, runCommand
}:
2023-04-03 13:18:27 +00:00
stdenv.mkDerivation (finalAttrs: {
pname = "pjsip";
version = "2.13";
2020-03-23 16:16:02 +00:00
src = fetchFromGitHub {
2023-04-03 13:18:27 +00:00
owner = finalAttrs.pname;
2020-03-23 16:16:02 +00:00
repo = "pjproject";
2023-04-03 13:18:27 +00:00
rev = finalAttrs.version;
sha256 = "sha256-yzszmm3uIyXtYFgZtUP3iswLx4u/8UbFt80Ln25ToFE=";
};
2020-04-08 19:29:11 +00:00
patches = [
./fix-aarch64.patch
(fetchpatch {
name = "CVE-2022-23537.patch";
url = "https://github.com/pjsip/pjproject/commit/d8440f4d711a654b511f50f79c0445b26f9dd1e1.patch";
sha256 = "sha256-7ueQCHIiJ7MLaWtR4+GmBc/oKaP+jmEajVnEYqiwLRA=";
})
(fetchpatch {
name = "CVE-2022-23547.patch";
url = "https://github.com/pjsip/pjproject/commit/bc4812d31a67d5e2f973fbfaf950d6118226cf36.patch";
sha256 = "sha256-bpc8e8VAQpfyl5PX96G++6fzkFpw3Or1PJKNPKl7N5k=";
})
2020-04-08 19:29:11 +00:00
];
2019-07-06 03:01:43 +00:00
2023-02-01 14:38:11 +00:00
nativeBuildInputs =
lib.optionals pythonSupport [ swig python3 ];
2020-04-08 19:29:11 +00:00
buildInputs = [ openssl libsamplerate ]
++ lib.optional stdenv.isLinux alsa-lib
++ lib.optionals stdenv.isDarwin [ AppKit CoreFoundation Security ];
2017-12-27 03:10:49 +00:00
preConfigure = ''
export LD=$CC
'';
NIX_CFLAGS_LINK = lib.optionalString stdenv.isDarwin "-headerpad_max_install_names";
2023-02-01 14:38:11 +00:00
postBuild = lib.optionalString pythonSupport ''
make -C pjsip-apps/src/swig/python
'';
configureFlags = [ "--enable-shared" ];
2023-02-01 14:38:11 +00:00
outputs = [ "out" ]
++ lib.optional pythonSupport "py";
postInstall = ''
mkdir -p $out/bin
cp pjsip-apps/bin/pjsua-* $out/bin/pjsua
2023-04-03 13:18:27 +00:00
mkdir -p $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
cp pjsip-apps/bin/samples/*/* $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
2023-02-01 14:38:11 +00:00
'' + lib.optionalString pythonSupport ''
(cd pjsip-apps/src/swig/python && \
python setup.py install --prefix=$py
)
'' + lib.optionalString stdenv.isDarwin ''
# On MacOS relative paths are used to refer to libraries. All libraries use
# a relative path like ../lib/*.dylib or ../../lib/*.dylib. We need to
# rewrite these to use absolute ones.
# First, find all libraries (and their symlinks) in our outputs to define
# the install_name_tool -change arguments we should pass.
readarray -t libraries < <(
for outputName in $(getAllOutputNames); do
find "''${!outputName}" \( -name '*.dylib*' -o -name '*.so*' \)
done
)
# Determine the install_name_tool -change arguments that are going to be
# applied to all libraries.
change_args=()
for lib in "''${libraries[@]}"; do
lib_name="$(basename $lib)"
change_args+=(-change ../lib/$lib_name $lib)
change_args+=(-change ../../lib/$lib_name $lib)
done
# Rewrite id and library refences for all non-symlinked libraries.
for lib in "''${libraries[@]}"; do
if [ -f "$lib" ]; then
install_name_tool -id $lib "''${change_args[@]}" $lib
fi
done
# Rewrite library references for all executables.
find "$out" -executable -type f | while read executable; do
install_name_tool "''${change_args[@]}" "$executable"
done
'';
# We need the libgcc_s.so.1 loadable (for pthread_cancel to work)
dontPatchELF = true;
passthru.tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "pjsua --version";
};
passthru.tests.pkg-config = testers.hasPkgConfigModule {
package = finalAttrs.finalPackage;
moduleName = "libpjproject";
};
passthru.tests.python-pjsua2 = runCommand "python-pjsua2" { } ''
${(python3.withPackages (pkgs: [ pkgs.pjsua2 ])).interpreter} -c "import pjsua2" > $out
'';
meta = with lib; {
2016-08-29 16:22:34 +00:00
description = "A multimedia communication library written in C, implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE";
homepage = "https://pjsip.org/";
2020-04-08 19:29:11 +00:00
license = licenses.gpl2Plus;
maintainers = with maintainers; [ olynch ];
mainProgram = "pjsua";
2020-04-08 19:29:11 +00:00
platforms = platforms.linux ++ platforms.darwin;
};
2023-04-03 13:18:27 +00:00
})