2021-12-06 16:07:01 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, openssl
|
|
|
|
, zlib
|
|
|
|
, libuv
|
2022-07-14 12:49:19 +00:00
|
|
|
# External poll is required for e.g. mosquitto, but discouraged by the maintainer.
|
2021-12-06 16:07:01 +00:00
|
|
|
, withExternalPoll ? false
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libwebsockets";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "4.3.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "warmcat";
|
|
|
|
repo = "libwebsockets";
|
|
|
|
rev = "v${version}";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = "sha256-IXA9NUh55GtZmn4BhCXntVdHcKZ34iZIJ/0wlySj0/M=";
|
2022-07-14 12:49:19 +00:00
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
buildInputs = [ openssl zlib libuv ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
nativeBuildInputs = [ cmake ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DLWS_WITH_PLUGINS=ON"
|
|
|
|
"-DLWS_WITH_IPV6=ON"
|
|
|
|
"-DLWS_WITH_SOCKS5=ON"
|
|
|
|
"-DDISABLE_WERROR=ON"
|
|
|
|
"-DLWS_BUILD_HASH=no_hash"
|
|
|
|
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "-DLWS_WITHOUT_TESTAPPS=ON"
|
2023-01-11 07:51:40 +00:00
|
|
|
++ lib.optional withExternalPoll "-DLWS_WITH_EXTERNAL_POLL=ON"
|
|
|
|
++ (
|
|
|
|
if stdenv.hostPlatform.isStatic then
|
|
|
|
[ "-DLWS_WITH_SHARED=OFF" ]
|
|
|
|
else
|
|
|
|
[ "-DLWS_WITH_STATIC=OFF" "-DLWS_LINK_TESTAPPS_DYNAMIC=ON" ]
|
|
|
|
);
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
postInstall = ''
|
2023-01-11 07:51:40 +00:00
|
|
|
# Fix path that will be incorrect on move to "dev" output.
|
|
|
|
substituteInPlace "$out/lib/cmake/libwebsockets/LibwebsocketsTargets-release.cmake" \
|
|
|
|
--replace "\''${_IMPORT_PREFIX}" "$out"
|
|
|
|
|
|
|
|
# The package builds a few test programs that are not usually necessary.
|
|
|
|
# Move those to the dev output.
|
|
|
|
moveToOutput "bin/libwebsockets-test-*" "$dev"
|
|
|
|
moveToOutput "share/libwebsockets-test-*" "$dev"
|
2022-07-14 12:49:19 +00:00
|
|
|
'';
|
2021-07-21 07:28:18 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
# $out/share/libwebsockets-test-server/plugins/libprotocol_*.so refers to crtbeginS.o
|
|
|
|
disallowedReferences = [ stdenv.cc.cc ];
|
2021-07-21 07:28:18 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
meta = with lib; {
|
|
|
|
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/";
|
|
|
|
# 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 ];
|
|
|
|
maintainers = with maintainers; [ mindavi ];
|
|
|
|
platforms = platforms.all;
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
2022-07-14 12:49:19 +00:00
|
|
|
|