1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 openssl,
6 libevent,
7 pkg-config,
8 libprom,
9 libmicrohttpd,
10 sqlite,
11 nixosTests,
12 systemdMinimal,
13}:
14
15stdenv.mkDerivation rec {
16 pname = "coturn";
17 version = "4.7.0";
18
19 src = fetchFromGitHub {
20 owner = "coturn";
21 repo = "coturn";
22 tag = version;
23 hash = "sha256-nvImelAvcbHpv6JTxX+sKpldVXG6u9Biu+VDt95r9I4=";
24 };
25
26 nativeBuildInputs = [
27 pkg-config
28 ];
29
30 buildInputs = [
31 openssl
32 (libevent.override { inherit openssl; })
33 libprom
34 libmicrohttpd
35 sqlite.dev
36 ]
37 ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform systemdMinimal) [
38 systemdMinimal
39 ];
40
41 patches = [
42 ./pure-configure.patch
43
44 # Don't call setgroups unconditionally in mainrelay
45 # https://github.com/coturn/coturn/pull/1508
46 ./dont-call-setgroups-unconditionally.patch
47 ];
48
49 configureFlags = [
50 # don't install examples due to broken symlinks
51 "--examplesdir=.."
52 ];
53
54 # Workaround build failure on -fno-common toolchains like upstream
55 # gcc-10. Otherwise build fails as:
56 # ld: ...-libprom-0.1.1/include/prom_collector_registry.h:37: multiple definition of
57 # `PROM_COLLECTOR_REGISTRY_DEFAULT'; ...-libprom-0.1.1/include/prom_collector_registry.h:37: first defined here
58 # Should be fixed in libprom-1.2.0 and later: https://github.com/digitalocean/prometheus-client-c/pull/25
59 env.NIX_CFLAGS_COMPILE = "-fcommon";
60
61 passthru.tests.coturn = nixosTests.coturn;
62
63 meta = {
64 description = "TURN server";
65 homepage = "https://coturn.net/";
66 changelog = "https://github.com/coturn/coturn/blob/${version}/ChangeLog";
67 license = with lib.licenses; [ bsd3 ];
68 platforms = lib.platforms.all;
69 maintainers = with lib.maintainers; [ _0x4A6F ];
70 broken = stdenv.hostPlatform.isDarwin; # 2018-10-21
71 };
72}