2021-12-06 16:07:01 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, openssl
|
|
|
|
, zlib
|
|
|
|
, libuv
|
2022-04-27 09:35:20 +00:00
|
|
|
, fetchpatch
|
2021-12-06 16:07:01 +00:00
|
|
|
# External poll is required for e.g. mosquitto, but discouraged by the maintainer.
|
|
|
|
, withExternalPoll ? false
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2022-04-27 09:35:20 +00:00
|
|
|
generic = { version, sha256, patches ? [] }: stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "libwebsockets";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "warmcat";
|
|
|
|
repo = "libwebsockets";
|
|
|
|
rev = "v${version}";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
inherit patches;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = [ openssl zlib libuv ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DLWS_WITH_PLUGINS=ON"
|
|
|
|
"-DLWS_WITH_IPV6=ON"
|
|
|
|
"-DLWS_WITH_SOCKS5=ON"
|
2021-07-14 22:03:04 +00:00
|
|
|
# Required since v4.2.0
|
|
|
|
"-DLWS_BUILD_HASH=no_hash"
|
2021-12-06 16:07:01 +00:00
|
|
|
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "-DLWS_WITHOUT_TESTAPPS=ON"
|
|
|
|
++ lib.optional withExternalPoll "-DLWS_WITH_EXTERNAL_POLL=ON";
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=unused-but-set-variable";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-07-21 07:28:18 +00: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-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00: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-02-05 17:12:51 +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-15 08:37:03 +00:00
|
|
|
maintainers = with maintainers; [ mindavi ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
in {
|
2020-04-24 23:36:52 +00:00
|
|
|
libwebsockets_3_1 = generic {
|
|
|
|
sha256 = "1w1wz6snf3cmcpa3f4dci2nz9za2f5rrylxl109id7bcb36xhbdl";
|
|
|
|
version = "3.1.0";
|
|
|
|
};
|
|
|
|
|
|
|
|
libwebsockets_3_2 = generic {
|
|
|
|
version = "3.2.2";
|
|
|
|
sha256 = "0m1kn4p167jv63zvwhsvmdn8azx3q7fkk8qc0fclwyps2scz6dna";
|
|
|
|
};
|
|
|
|
|
2021-07-14 22:03:04 +00:00
|
|
|
libwebsockets_4_2 = generic {
|
2021-08-27 14:25:00 +00:00
|
|
|
version = "4.2.1";
|
|
|
|
sha256 = "sha256-C+WGfNF4tAgbp/7aRraBgjNOe4I5ihm+8CGelXzfxbU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
libwebsockets_4_3 = generic {
|
2022-04-27 09:35:20 +00:00
|
|
|
version = "4.3.1";
|
|
|
|
sha256 = "sha256-lB3JHh058cQc5rycLnHk3JAOgtku0nRCixN5U6lPKq8=";
|
|
|
|
patches = [
|
|
|
|
# fixes the propagated cmake files, fixing the build of ttyd
|
|
|
|
# see also https://github.com/tsl0922/ttyd/issues/918
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/warmcat/libwebsockets/commit/99a8b9c4422bed45c8b7412a1e121056f2a6132a.patch";
|
|
|
|
hash = "sha256-zHBo2ZEayvibM+jzeVaZqySxghaOLUglpSFwuGhl6HM=";
|
|
|
|
})
|
|
|
|
];
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|