1{
2 fetchFromGitHub,
3 stdenv,
4 lib,
5 pkg-config,
6 autoreconfHook,
7 ncurses,
8 gnutls,
9 readline,
10 openssl,
11 perl,
12 sqlite,
13 libjpeg,
14 speex,
15 pcre,
16 libuuid,
17 ldns,
18 libedit,
19 yasm,
20 which,
21 libsndfile,
22 libtiff,
23 libxcrypt,
24 callPackage,
25 modules ? null,
26 nixosTests,
27}:
28
29let
30
31 availableModules = callPackage ./modules.nix { };
32
33 # the default list from v1.8.7, except with applications/mod_signalwire also disabled
34 defaultModules =
35 mods:
36 with mods;
37 [
38 applications.commands
39 applications.conference
40 applications.db
41 applications.dptools
42 applications.enum
43 applications.esf
44 applications.expr
45 applications.fifo
46 applications.fsv
47 applications.hash
48 applications.httapi
49 applications.sms
50 applications.spandsp
51 applications.valet_parking
52 applications.voicemail
53
54 applications.curl
55
56 codecs.amr
57 codecs.b64
58 codecs.g723_1
59 codecs.g729
60 codecs.h26x
61 codecs.opus
62
63 databases.mariadb
64 databases.pgsql
65
66 dialplans.asterisk
67 dialplans.xml
68
69 endpoints.loopback
70 endpoints.rtc
71 endpoints.skinny
72 endpoints.sofia
73 endpoints.verto
74
75 event_handlers.cdr_csv
76 event_handlers.cdr_sqlite
77 event_handlers.event_socket
78
79 formats.local_stream
80 formats.native_file
81 formats.png
82 formats.sndfile
83 formats.tone_stream
84
85 languages.lua
86
87 loggers.console
88 loggers.logfile
89 loggers.syslog
90
91 say.en
92
93 xml_int.cdr
94 xml_int.rpc
95 xml_int.scgi
96 ]
97 ++ lib.optionals stdenv.hostPlatform.isLinux [ endpoints.gsmopen ];
98
99 enabledModules = (if modules != null then modules else defaultModules) availableModules;
100
101 modulesConf =
102 let
103 lst = builtins.map (mod: mod.path) enabledModules;
104 str = lib.strings.concatStringsSep "\n" lst;
105 in
106 builtins.toFile "modules.conf" str;
107
108in
109
110stdenv.mkDerivation rec {
111 pname = "freeswitch";
112 version = "1.10.12";
113 src = fetchFromGitHub {
114 owner = "signalwire";
115 repo = "freeswitch";
116 rev = "v${version}";
117 hash = "sha256-uOO+TpKjJkdjEp4nHzxcHtZOXqXzpkIF3dno1AX17d8=";
118 };
119
120 postPatch = ''
121 patchShebangs libs/libvpx/build/make/rtcd.pl
122 substituteInPlace libs/libvpx/build/make/configure.sh \
123 --replace AS=\''${AS} AS=yasm
124
125 # Disable advertisement banners
126 for f in src/include/cc.h libs/esl/src/include/cc.h; do
127 {
128 echo 'const char *cc = "";'
129 echo 'const char *cc_s = "";'
130 } > $f
131 done
132 '';
133
134 strictDeps = true;
135 nativeBuildInputs = [
136 pkg-config
137 autoreconfHook
138 perl
139 which
140 yasm
141 ];
142 buildInputs = [
143 openssl
144 ncurses
145 gnutls
146 readline
147 libjpeg
148 sqlite
149 pcre
150 speex
151 ldns
152 libedit
153 libsndfile
154 libtiff
155 libuuid
156 libxcrypt
157 ]
158 ++ lib.unique (lib.concatMap (mod: mod.inputs) enabledModules);
159
160 enableParallelBuilding = true;
161
162 env.NIX_CFLAGS_COMPILE = toString [
163 "-Wno-error"
164 # https://github.com/signalwire/freeswitch/issues/2495
165 "-Wno-incompatible-pointer-types"
166 ];
167
168 # Using c++14 because of build error
169 # gsm_at.h:94:32: error: ISO C++17 does not allow dynamic exception specifications
170 CXXFLAGS = "-std=c++14";
171
172 CFLAGS = "-D_ANSI_SOURCE";
173
174 hardeningDisable = [ "format" ];
175
176 preConfigure = ''
177 ./bootstrap.sh
178 cp "${modulesConf}" modules.conf
179 '';
180
181 postInstall = ''
182 # helper for compiling modules... not generally useful; also pulls in perl dependency
183 rm "$out"/bin/fsxs
184 # include configuration templates
185 cp -r conf $out/share/freeswitch/
186 '';
187
188 passthru.tests.freeswitch = nixosTests.freeswitch;
189
190 meta = {
191 description = "Cross-Platform Scalable FREE Multi-Protocol Soft Switch";
192 homepage = "https://freeswitch.org/";
193 license = lib.licenses.mpl11;
194 maintainers = with lib.maintainers; [ mikaelfangel ];
195 platforms = with lib.platforms; unix;
196 broken = stdenv.hostPlatform.isDarwin;
197 };
198}