17 stdenv.mkDerivation (finalAttrs: {
21 src = fetchFromGitHub {
24 rev = "refs/tags/${finalAttrs.version}";
25 hash = "sha256-LDA3o1QMrAxcGuOi/YRoMzXmw/wFkfDs2wweZuIJ2RY=";
28 patches = [ ./fix-aarch64.patch ];
32 pjsip-apps/src/py_pjsua/setup.py \
33 pjsip-apps/src/swig/python/setup.py \
34 pjsip-apps/src/python/setup.py \
35 pjsip-apps/src/python/setup-vc.py \
36 --replace-fail "distutils.core" "setuptools"
39 nativeBuildInputs = lib.optionals pythonSupport [
43 python3.pkgs.installer
44 python3.pkgs.setuptools
53 ++ lib.optional stdenv.hostPlatform.isLinux alsa-lib
54 ++ lib.optionals stdenv.hostPlatform.isDarwin [
61 lib.optionalAttrs stdenv.cc.isClang { CXXFLAGS = "-std=c++11"; }
62 // lib.optionalAttrs stdenv.hostPlatform.isDarwin {
63 NIX_CFLAGS_LINK = "-headerpad_max_install_names";
70 postBuild = lib.optionalString pythonSupport ''
71 make -C pjsip-apps/src/swig/python
74 configureFlags = [ "--enable-shared" ];
76 outputs = [ "out" ] ++ lib.optional pythonSupport "py";
81 cp pjsip-apps/bin/pjsua-* $out/bin/pjsua
82 mkdir -p $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
83 cp pjsip-apps/bin/samples/*/* $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
85 + lib.optionalString pythonSupport ''
86 (cd pjsip-apps/src/swig/python && \
87 python -m build --no-isolation --outdir dist/ --wheel
88 python -m installer --prefix $py dist/*.whl
91 + lib.optionalString stdenv.hostPlatform.isDarwin ''
92 # On MacOS relative paths are used to refer to libraries. All libraries use
93 # a relative path like ../lib/*.dylib or ../../lib/*.dylib. We need to
94 # rewrite these to use absolute ones.
96 # First, find all libraries (and their symlinks) in our outputs to define
97 # the install_name_tool -change arguments we should pass.
98 readarray -t libraries < <(
99 for outputName in $(getAllOutputNames); do
100 find "''${!outputName}" \( -name '*.dylib*' -o -name '*.so*' \)
104 # Determine the install_name_tool -change arguments that are going to be
105 # applied to all libraries.
107 for lib in "''${libraries[@]}"; do
108 lib_name="$(basename $lib)"
109 change_args+=(-change ../lib/$lib_name $lib)
110 change_args+=(-change ../../lib/$lib_name $lib)
113 # Rewrite id and library refences for all non-symlinked libraries.
114 for lib in "''${libraries[@]}"; do
115 if [ -f "$lib" ]; then
116 install_name_tool -id $lib "''${change_args[@]}" $lib
120 # Rewrite library references for all executables.
121 find "$out" -executable -type f | while read executable; do
122 install_name_tool "''${change_args[@]}" "$executable"
126 # We need the libgcc_s.so.1 loadable (for pthread_cancel to work)
129 passthru.tests.version = testers.testVersion {
130 package = finalAttrs.finalPackage;
131 command = "pjsua --version";
134 passthru.tests.pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
136 passthru.tests.python-pjsua2 = runCommand "python-pjsua2" { } ''
137 ${(python3.withPackages (pkgs: [ pkgs.pjsua2 ])).interpreter} -c "import pjsua2" > $out
141 description = "Multimedia communication library written in C, implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE";
142 homepage = "https://pjsip.org/";
143 license = licenses.gpl2Plus;
144 maintainers = with maintainers; [ olynch ];
145 mainProgram = "pjsua";
146 platforms = platforms.linux ++ platforms.darwin;
147 pkgConfigModules = [ "libpjproject" ];