about summary refs log tree commit diff
path: root/pkgs/servers/sip/kamailio/default.nix
blob: 5fd4a63281c0e3debc0e7ef13f849f8f4a3eb3b9 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{ callPackage
, fetchurl
, lib
, stdenv
, pkg-config
, which
, bison
, flex
, json_c
, libevent
, libxml2
, mariadb-connector-c
, pcre
, gnugrep
, gawk
, coreutils
, gdb
, gnused
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "kamailio";
  version = "5.7.3";

  src = fetchurl {
    url = "https://www.kamailio.org/pub/kamailio/${finalAttrs.version}/src/kamailio-${finalAttrs.version}_src.tar.gz";
    hash = "sha256-x6YgsDl05OBNQZ4Iancf0Leo4mnz1pwZocZghaSY/Yw=";
  };

  buildInputs = [
    json_c
    libevent
    libxml2
    mariadb-connector-c
    pcre
  ];

  nativeBuildInputs = [
    pkg-config
    which
    bison
    flex
  ];

  configurePhase = let
    modules = [
      "db_mysql"
      "dialplan"
      "jsonrpcc"
      "json"
      "lcr"
      "presence"
      "presence_conference"
      "presence_dialoginfo"
      "presence_mwi"
      "presence_profile"
      "presence_reginfo"
      "presence_xml"
      "pua"
      "pua_bla"
      "pua_dialoginfo"
      "pua_json"
      "pua_reginfo"
      "pua_rpc"
      "pua_usrloc"
      "pua_xmpp"
      "regex"
      "rls"
      "xcap_client"
      "xcap_server"
    ];
   in ''
    runHook preConfigure

    make PREFIX="$out" include_modules="${lib.concatStringsSep " " modules}" cfg

    runHook postConfigure
  '';

  preInstall = ''
    makeFlagsArray+=(PREFIX="$out" "MYSQLCFG=${lib.getDev mariadb-connector-c}/bin/mariadb_config")
  '';

  postInstall = ''
    echo 'MD5="${coreutils}/bin/md5sum"' >> $out/etc/kamailio/kamctlrc
    echo 'AWK="${gawk}/bin/awk"' >> $out/etc/kamailio/kamctlrc
    echo 'GDB="${gdb}/bin/gdb"' >> $out/etc/kamailio/kamctlrc
    echo 'GREP="${gnugrep}/bin/grep "' >> $out/etc/kamailio/kamctlrc
    echo 'EGREP="${gnugrep}/bin/grep -E"' >> $out/etc/kamailio/kamctlrc
    echo 'SED="${gnused}/bin/sed"' >> $out/etc/kamailio/kamctlrc
    echo 'LAST_LINE="${coreutils}/bin/tail -n 1"' >> $out/etc/kamailio/kamctlrc
    echo 'EXPR="${gnugrep}/bin/expr"' >> $out/etc/kamailio/kamctlrc
  '';

  enableParallelBuilding = true;

  passthru.tests = {
    kamailio-bin = callPackage ./test-kamailio-bin { };
  };

  meta = {
    description = "Fast and flexible SIP server, proxy, SBC, and load balancer";
    homepage = "https://www.kamailio.org/";
    license = lib.licenses.gpl2Only;
    maintainers = with lib.maintainers; [ mawis ];
    platforms = lib.platforms.linux;
  };
})