Commit 1b6bf4b9 authored by eljamm's avatar eljamm
Browse files

python3Packages.sipsimple: rename and modernize

- Follow upstream and rename from `sipsimple` to `python3-sipsimple`
- Use `finalAttrs` fixpoint pattern
parent 9ead6815
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ python3Packages.buildPythonApplication rec {
    python3-application
    python3-eventlib
    python3-gnutls
    sipsimple
    python3-sipsimple
    sqlobject
    standard-imghdr
    xcaplib
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ python3Packages.buildPythonApplication rec {
    msrplib
    python3-eventlib
    python3-gnutls
    sipsimple
    python3-sipsimple
    wokkel
    xcaplib
  ];
+42 −45
Original line number Diff line number Diff line
@@ -20,44 +20,7 @@
  x264,
  python3-application,
}:

let
  extDeps = {
    pjsip = rec {
      # Hardcoded in get_dependencies.sh, checked at buildtime
      # need tarball specifically for buildscript to detect it
      version = "2.10";
      src = fetchurl {
        url = "https://github.com/pjsip/pjproject/archive/${version}.tar.gz";
        hash = "sha256-k2pMW5hgG1IyVGOjl93xGrQQbGp7BPjcfN03fvu1l94=";
      };
      patches = [
        # Backported https://github.com/pjsip/pjproject/commit/4a8d180529d6ffb0760838b1f8cadc4cb5f7ac03
        ./pjsip-0001-NEON.patch

        # Backported https://github.com/pjsip/pjproject/commit/f56fd48e23982c47f38574a3fd93ebf248ef3762
        ./pjsip-0002-RISC-V.patch

        # Backported https://github.com/pjsip/pjproject/commit/f94b18ef6e0c0b5d34eb274f85ac0a3b2cf9107a
        ./pjsip-0003-LoongArch64.patch
      ];
    };
    zrtpcpp = rec {
      # Hardcoded in get_dependencies.sh, NOT checked at buildtime
      rev = "6b3cd8e6783642292bad0c21e3e5e5ce45ff3e03";
      src = fetchFromGitHub {
        owner = "wernerd";
        repo = "ZRTPCPP";
        inherit rev;
        hash = "sha256-pGng1Y9N51nGBpiZbn2NTx4t2NGg4qkmbghTscJVhIA=";
        postFetch = ''
          # fix build with gcc15
          sed -e '9i #include <cstdint>' -i $out/zrtp/EmojiBase32.cpp
        '';
      };
    };
  };

  applyPatchesWhenAvailable =
    extDep: dir:
    lib.optionalString (extDep ? patches) (
@@ -67,7 +30,7 @@ let
      '') extDep.patches
    );
in
buildPythonPackage rec {
buildPythonPackage (finalAttrs: {
  pname = "python3-sipsimple";
  version = "5.3.3.2";
  pyproject = true;
@@ -75,7 +38,7 @@ buildPythonPackage rec {
  src = fetchFromGitHub {
    owner = "AGProjects";
    repo = "python3-sipsimple";
    tag = "${version}-mac";
    tag = "${finalAttrs.version}-mac";
    hash = "sha256-kDXVzLmgfXxm8phKrV7DvPuZ9O2iNFo1s6Lc0jcc/dM=";
  };

@@ -122,13 +85,13 @@ buildPythonPackage rec {
  ];

  preConfigure = ''
    ln -s ${passthru.extDeps.pjsip.src} deps/${passthru.extDeps.pjsip.version}.tar.gz
    cp -r --no-preserve=all ${passthru.extDeps.zrtpcpp.src} deps/ZRTPCPP
    ln -s ${finalAttrs.passthru.extDeps.pjsip.src} deps/${finalAttrs.passthru.extDeps.pjsip.version}.tar.gz
    cp -r --no-preserve=all ${finalAttrs.passthru.extDeps.zrtpcpp.src} deps/ZRTPCPP

    bash ./get_dependencies.sh
  ''
  + applyPatchesWhenAvailable extDeps.pjsip "deps/pjsip"
  + applyPatchesWhenAvailable extDeps.zrtpcpp "deps/ZRTPCPP"
  + applyPatchesWhenAvailable finalAttrs.passthru.extDeps.pjsip "deps/pjsip"
  + applyPatchesWhenAvailable finalAttrs.passthru.extDeps.zrtpcpp "deps/ZRTPCPP"
  + ''
    # Fails to link some static libs due to missing -lc DSO. Just use the compiler frontend instead of raw ld.
    substituteInPlace deps/pjsip/build/rules.mak \
@@ -145,13 +108,47 @@ buildPythonPackage rec {
  pythonImportsCheck = [ "sipsimple" ];

  passthru = {
    inherit extDeps;
    updateScript = nix-update-script {
      extraArgs = [
        "--version-regex"
        "^(.*)-mac$"
      ];
    };
    extDeps = {
      pjsip = rec {
        # Hardcoded in get_dependencies.sh, checked at buildtime
        # need tarball specifically for buildscript to detect it
        version = "2.10";
        src = fetchurl {
          url = "https://github.com/pjsip/pjproject/archive/${version}.tar.gz";
          hash = "sha256-k2pMW5hgG1IyVGOjl93xGrQQbGp7BPjcfN03fvu1l94=";
        };
        patches = [
          # Backported https://github.com/pjsip/pjproject/commit/4a8d180529d6ffb0760838b1f8cadc4cb5f7ac03
          ./pjsip-0001-NEON.patch

          # Backported https://github.com/pjsip/pjproject/commit/f56fd48e23982c47f38574a3fd93ebf248ef3762
          ./pjsip-0002-RISC-V.patch

          # Backported https://github.com/pjsip/pjproject/commit/f94b18ef6e0c0b5d34eb274f85ac0a3b2cf9107a
          ./pjsip-0003-LoongArch64.patch
        ];
      };
      zrtpcpp = rec {
        # Hardcoded in get_dependencies.sh, NOT checked at buildtime
        rev = "6b3cd8e6783642292bad0c21e3e5e5ce45ff3e03";
        src = fetchFromGitHub {
          owner = "wernerd";
          repo = "ZRTPCPP";
          inherit rev;
          hash = "sha256-pGng1Y9N51nGBpiZbn2NTx4t2NGg4qkmbghTscJVhIA=";
          postFetch = ''
            # fix build with gcc15
            sed -e '9i #include <cstdint>' -i $out/zrtp/EmojiBase32.cpp
          '';
        };
      };
    };
  };

  meta = {
@@ -162,4 +159,4 @@ buildPythonPackage rec {
    teams = [ lib.teams.ngi ];
    maintainers = [ lib.maintainers.ethancedwards8 ];
  };
}
})
Loading