python312Packages.llama-index: 0.12.9 -> 0.12.9.post1 (#371957)
[NixPkgs.git] / pkgs / by-name / li / libwebsockets / package.nix
blobdfad04d7f4d188daa2040a2b7f2c36be1becaaca
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   cmake,
6   openssl,
7   zlib,
8   libuv,
9   # External poll is required for e.g. mosquitto, but discouraged by the maintainer.
10   withExternalPoll ? false,
13 stdenv.mkDerivation rec {
14   pname = "libwebsockets";
15   version = "4.3.3";
17   src = fetchFromGitHub {
18     owner = "warmcat";
19     repo = "libwebsockets";
20     rev = "v${version}";
21     hash = "sha256-IXA9NUh55GtZmn4BhCXntVdHcKZ34iZIJ/0wlySj0/M=";
22   };
24   outputs = [
25     "out"
26     "dev"
27   ];
29   buildInputs = [
30     openssl
31     zlib
32     libuv
33   ];
35   nativeBuildInputs = [ cmake ];
37   cmakeFlags =
38     [
39       "-DLWS_WITH_PLUGINS=ON"
40       "-DLWS_WITH_IPV6=ON"
41       "-DLWS_WITH_SOCKS5=ON"
42       "-DDISABLE_WERROR=ON"
43       "-DLWS_BUILD_HASH=no_hash"
44     ]
45     ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "-DLWS_WITHOUT_TESTAPPS=ON"
46     ++ lib.optional withExternalPoll "-DLWS_WITH_EXTERNAL_POLL=ON"
47     ++ (
48       if stdenv.hostPlatform.isStatic then
49         [ "-DLWS_WITH_SHARED=OFF" ]
50       else
51         [
52           "-DLWS_WITH_STATIC=OFF"
53           "-DLWS_LINK_TESTAPPS_DYNAMIC=ON"
54         ]
55     );
57   postInstall = ''
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"
66   '';
68   # $out/share/libwebsockets-test-server/plugins/libprotocol_*.so refers to crtbeginS.o
69   disallowedReferences = [ stdenv.cc.cc ];
71   meta = with lib; {
72     description = "Light, portable C library for websockets";
73     longDescription = ''
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.
77     '';
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; [
82       mit
83       publicDomain
84       bsd3
85       asl20
86     ];
87     maintainers = with maintainers; [ mindavi ];
88     platforms = platforms.all;
89   };