9 # External poll is required for e.g. mosquitto, but discouraged by the maintainer.
10 withExternalPoll ? false,
13 stdenv.mkDerivation rec {
14 pname = "libwebsockets";
17 src = fetchFromGitHub {
19 repo = "libwebsockets";
21 hash = "sha256-IXA9NUh55GtZmn4BhCXntVdHcKZ34iZIJ/0wlySj0/M=";
35 nativeBuildInputs = [ cmake ];
39 "-DLWS_WITH_PLUGINS=ON"
41 "-DLWS_WITH_SOCKS5=ON"
43 "-DLWS_BUILD_HASH=no_hash"
45 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "-DLWS_WITHOUT_TESTAPPS=ON"
46 ++ lib.optional withExternalPoll "-DLWS_WITH_EXTERNAL_POLL=ON"
48 if stdenv.hostPlatform.isStatic then
49 [ "-DLWS_WITH_SHARED=OFF" ]
52 "-DLWS_WITH_STATIC=OFF"
53 "-DLWS_LINK_TESTAPPS_DYNAMIC=ON"
58 # Fix path that will be incorrect on move to "dev" output.
59 substituteInPlace "$out/lib/cmake/libwebsockets/LibwebsocketsTargets-release.cmake" \
60 --replace "\''${_IMPORT_PREFIX}" "$out"
62 # The package builds a few test programs that are not usually necessary.
63 # Move those to the dev output.
64 moveToOutput "bin/libwebsockets-test-*" "$dev"
65 moveToOutput "share/libwebsockets-test-*" "$dev"
68 # $out/share/libwebsockets-test-server/plugins/libprotocol_*.so refers to crtbeginS.o
69 disallowedReferences = [ stdenv.cc.cc ];
72 description = "Light, portable C library for websockets";
74 Libwebsockets is a lightweight pure C library built to
75 use minimal CPU and memory resources, and provide fast
76 throughput in both directions.
78 homepage = "https://libwebsockets.org/";
79 # Relicensed from LGPLv2.1+ to MIT with 4.0. Licensing situation
80 # is tricky, see https://github.com/warmcat/libwebsockets/blob/main/LICENSE
81 license = with licenses; [
87 maintainers = with maintainers; [ mindavi ];
88 platforms = platforms.all;