Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchFromGitHub 4, cmake 5, openssl 6, zlib 7, libuv 8 # External poll is required for e.g. mosquitto, but discouraged by the maintainer. 9, withExternalPoll ? false 10}: 11 12stdenv.mkDerivation rec { 13 pname = "libwebsockets"; 14 version = "4.3.2"; 15 16 src = fetchFromGitHub { 17 owner = "warmcat"; 18 repo = "libwebsockets"; 19 rev = "v${version}"; 20 hash = "sha256-why8LAcc4XN0JdTJ1JoNWijKENL5mOHBsi9K4wpYr2c="; 21 }; 22 23 outputs = [ "out" "dev" ]; 24 25 buildInputs = [ openssl zlib libuv ]; 26 27 nativeBuildInputs = [ cmake ]; 28 29 cmakeFlags = [ 30 "-DLWS_WITH_PLUGINS=ON" 31 "-DLWS_WITH_IPV6=ON" 32 "-DLWS_WITH_SOCKS5=ON" 33 "-DDISABLE_WERROR=ON" 34 "-DLWS_BUILD_HASH=no_hash" 35 ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "-DLWS_WITHOUT_TESTAPPS=ON" 36 ++ lib.optional withExternalPoll "-DLWS_WITH_EXTERNAL_POLL=ON" 37 ++ ( 38 if stdenv.hostPlatform.isStatic then 39 [ "-DLWS_WITH_SHARED=OFF" ] 40 else 41 [ "-DLWS_WITH_STATIC=OFF" "-DLWS_LINK_TESTAPPS_DYNAMIC=ON" ] 42 ); 43 44 postInstall = '' 45 # Fix path that will be incorrect on move to "dev" output. 46 substituteInPlace "$out/lib/cmake/libwebsockets/LibwebsocketsTargets-release.cmake" \ 47 --replace "\''${_IMPORT_PREFIX}" "$out" 48 49 # The package builds a few test programs that are not usually necessary. 50 # Move those to the dev output. 51 moveToOutput "bin/libwebsockets-test-*" "$dev" 52 moveToOutput "share/libwebsockets-test-*" "$dev" 53 ''; 54 55 # $out/share/libwebsockets-test-server/plugins/libprotocol_*.so refers to crtbeginS.o 56 disallowedReferences = [ stdenv.cc.cc ]; 57 58 meta = with lib; { 59 description = "Light, portable C library for websockets"; 60 longDescription = '' 61 Libwebsockets is a lightweight pure C library built to 62 use minimal CPU and memory resources, and provide fast 63 throughput in both directions. 64 ''; 65 homepage = "https://libwebsockets.org/"; 66 # Relicensed from LGPLv2.1+ to MIT with 4.0. Licensing situation 67 # is tricky, see https://github.com/warmcat/libwebsockets/blob/main/LICENSE 68 license = with licenses; [ mit publicDomain bsd3 asl20 ]; 69 maintainers = with maintainers; [ mindavi ]; 70 platforms = platforms.all; 71 }; 72} 73