summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/fr/freeswitch/package.nix
blob: f8a2d2e02dc942ed24075c77200c45d8e7375c7c (plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
{
  fetchFromGitHub,
  stdenv,
  lib,
  pkg-config,
  autoreconfHook,
  ncurses,
  gnutls,
  readline,
  openssl,
  perl,
  sqlite,
  libjpeg,
  speex,
  pcre2,
  libuuid,
  ldns,
  libedit,
  yasm,
  which,
  libsndfile,
  libtiff,
  libxcrypt,
  callPackage,
  modules ? null,
  nixosTests,
}:

let

  availableModules = callPackage ./modules.nix { };

  # the default list from v1.8.7, except with applications/mod_signalwire also disabled
  defaultModules =
    mods:
    with mods;
    [
      applications.commands
      applications.conference
      applications.db
      applications.dptools
      applications.enum
      applications.esf
      applications.expr
      applications.fifo
      applications.fsv
      applications.hash
      applications.httapi
      applications.sms
      applications.spandsp
      applications.valet_parking
      applications.voicemail

      applications.curl

      codecs.amr
      codecs.b64
      codecs.g723_1
      codecs.g729
      codecs.h26x
      codecs.opus

      databases.mariadb
      databases.pgsql

      dialplans.asterisk
      dialplans.xml

      endpoints.loopback
      endpoints.rtc
      endpoints.skinny
      endpoints.sofia
      endpoints.verto

      event_handlers.cdr_csv
      event_handlers.cdr_sqlite
      event_handlers.event_socket

      formats.local_stream
      formats.native_file
      formats.png
      formats.sndfile
      formats.tone_stream

      languages.lua

      loggers.console
      loggers.logfile
      loggers.syslog

      say.en

      xml_int.cdr
      xml_int.rpc
      xml_int.scgi
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [ endpoints.gsmopen ];

  enabledModules = (if modules != null then modules else defaultModules) availableModules;

  modulesConf =
    let
      lst = map (mod: mod.path) enabledModules;
      str = lib.strings.concatStringsSep "\n" lst;
    in
    builtins.toFile "modules.conf" str;

in

stdenv.mkDerivation (finalAttrs: {
  pname = "freeswitch";
  version = "1.11.1";
  src = fetchFromGitHub {
    owner = "signalwire";
    repo = "freeswitch";
    rev = "v${finalAttrs.version}";
    hash = "sha256-uXn5MLEsGPfRzTQJ/v3Tq1yXVIWZQwNQIyvZulMxSqU=";
  };

  postPatch = ''
    patchShebangs     libs/libvpx/build/make/rtcd.pl
    substituteInPlace libs/libvpx/build/make/configure.sh \
      --replace AS=\''${AS} AS=yasm

    # Disable advertisement banners
    for f in src/include/cc.h libs/esl/src/include/cc.h; do
      {
        echo 'const char *cc = "";'
        echo 'const char *cc_s = "";'
      } > $f
    done
  '';

  strictDeps = true;
  nativeBuildInputs = [
    pkg-config
    autoreconfHook
    perl
    which
    yasm
  ];
  buildInputs = [
    openssl
    ncurses
    gnutls
    readline
    libjpeg
    sqlite
    pcre2
    speex
    ldns
    libedit
    libsndfile
    libtiff
    libuuid
    libxcrypt
  ]
  ++ lib.unique (lib.concatMap (mod: mod.inputs) enabledModules);

  enableParallelBuilding = true;

  env = {
    NIX_CFLAGS_COMPILE = toString [
      "-Wno-error"
      # https://github.com/signalwire/freeswitch/issues/2495
      "-Wno-incompatible-pointer-types"
    ];

    # Using c++14 because of build error
    # gsm_at.h:94:32: error: ISO C++17 does not allow dynamic exception specifications
    CXXFLAGS = "-std=c++14";

    CFLAGS = "-D_ANSI_SOURCE";
  };

  hardeningDisable = [ "format" ];

  preConfigure = ''
    ./bootstrap.sh
    cp "${modulesConf}" modules.conf
  '';

  postInstall = ''
    # helper for compiling modules... not generally useful; also pulls in perl dependency
    rm "$out"/bin/fsxs
    # include configuration templates
    cp -r conf $out/share/freeswitch/
  '';

  passthru.tests.freeswitch = nixosTests.freeswitch;

  meta = {
    description = "Cross-Platform Scalable FREE Multi-Protocol Soft Switch";
    homepage = "https://freeswitch.org/";
    license = lib.licenses.mpl11;
    maintainers = with lib.maintainers; [ mikaelfangel ];
    platforms = with lib.platforms; unix;
    broken = stdenv.hostPlatform.isDarwin;
  };
})