2021-10-09 11:43:01 +01:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, openssl
|
|
|
|
, zlib
|
|
|
|
, libuv
|
2021-11-23 18:15:33 +00:00
|
|
|
# External poll is required for e.g. mosquitto, but discouraged by the maintainer.
|
|
|
|
, withExternalPoll ? false
|
2021-10-09 11:43:01 +01:00
|
|
|
}:
|
2015-09-13 19:49:13 +01:00
|
|
|
|
2019-09-16 05:28:30 +01:00
|
|
|
let
|
|
|
|
generic = { version, sha256 }: stdenv.mkDerivation rec {
|
|
|
|
pname = "libwebsockets";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "warmcat";
|
|
|
|
repo = "libwebsockets";
|
|
|
|
rev = "v${version}";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ openssl zlib libuv ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
|
2020-07-06 23:59:24 +01:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DLWS_WITH_PLUGINS=ON"
|
|
|
|
"-DLWS_WITH_IPV6=ON"
|
|
|
|
"-DLWS_WITH_SOCKS5=ON"
|
2021-05-15 17:50:55 +01:00
|
|
|
# Required since v4.2.0
|
|
|
|
"-DLWS_BUILD_HASH=no_hash"
|
2021-11-23 18:15:33 +00:00
|
|
|
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "-DLWS_WITHOUT_TESTAPPS=ON"
|
|
|
|
++ lib.optional withExternalPoll "-DLWS_WITH_EXTERNAL_POLL=ON";
|
2020-07-06 23:59:24 +01:00
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=unused-but-set-variable";
|
2019-09-16 05:28:30 +01:00
|
|
|
|
2021-07-20 09:47:18 +01:00
|
|
|
postInstall = ''
|
|
|
|
rm -r ${placeholder "out"}/share/libwebsockets-test-server
|
|
|
|
'';
|
|
|
|
|
|
|
|
# $out/share/libwebsockets-test-server/plugins/libprotocol_*.so refers to crtbeginS.o
|
|
|
|
disallowedReferences = [ stdenv.cc.cc ];
|
2021-07-19 10:36:01 +01:00
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2019-09-16 05:28:30 +01:00
|
|
|
description = "Light, portable C library for websockets";
|
|
|
|
longDescription = ''
|
|
|
|
Libwebsockets is a lightweight pure C library built to
|
|
|
|
use minimal CPU and memory resources, and provide fast
|
|
|
|
throughput in both directions.
|
|
|
|
'';
|
|
|
|
homepage = "https://libwebsockets.org/";
|
2021-01-30 22:41:14 +00:00
|
|
|
# Relicensed from LGPLv2.1+ to MIT with 4.0. Licensing situation
|
|
|
|
# is tricky, see https://github.com/warmcat/libwebsockets/blob/main/LICENSE
|
|
|
|
license = with licenses; [ mit publicDomain bsd3 asl20 ];
|
2021-03-12 18:21:12 +00:00
|
|
|
maintainers = with maintainers; [ mindavi ];
|
2019-09-16 05:28:30 +01:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
2015-09-13 19:49:13 +01:00
|
|
|
};
|
|
|
|
|
2021-07-19 10:36:01 +01:00
|
|
|
in {
|
2019-09-16 05:28:30 +01:00
|
|
|
libwebsockets_3_1 = generic {
|
|
|
|
sha256 = "1w1wz6snf3cmcpa3f4dci2nz9za2f5rrylxl109id7bcb36xhbdl";
|
|
|
|
version = "3.1.0";
|
2015-09-13 19:49:13 +01:00
|
|
|
};
|
2019-09-16 05:28:30 +01:00
|
|
|
|
|
|
|
libwebsockets_3_2 = generic {
|
2020-03-05 00:00:57 +00:00
|
|
|
version = "3.2.2";
|
|
|
|
sha256 = "0m1kn4p167jv63zvwhsvmdn8azx3q7fkk8qc0fclwyps2scz6dna";
|
2019-09-16 05:28:30 +01:00
|
|
|
};
|
|
|
|
|
2021-05-15 17:50:55 +01:00
|
|
|
libwebsockets_4_2 = generic {
|
2021-08-26 11:52:13 +01:00
|
|
|
version = "4.2.1";
|
|
|
|
sha256 = "sha256-C+WGfNF4tAgbp/7aRraBgjNOe4I5ihm+8CGelXzfxbU=";
|
2021-05-15 17:50:55 +01:00
|
|
|
};
|
2021-10-09 11:43:01 +01:00
|
|
|
|
|
|
|
libwebsockets_4_3 = generic {
|
|
|
|
version = "4.3.0";
|
|
|
|
sha256 = "13lxb487mqlzbsbv6fbj50r1717mfwdy87ps592lgfy3307yqpr4";
|
|
|
|
};
|
2015-09-13 19:49:13 +01:00
|
|
|
}
|