1{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, curl, openssl, Security }:
2
3stdenv.mkDerivation (finalAttrs: {
4 pname = "libhv";
5 version = "1.3.2";
6
7 src = fetchFromGitHub {
8 owner = "ithewei";
9 repo = "libhv";
10 rev = "v${finalAttrs.version}";
11 hash = "sha256-tVuQwj2HvAhp51urGCuNPjBEIaTu9yR031Ih/5or9Pk=";
12 };
13
14 patches = [
15 # Fix build failure on gcc-13:
16 # https://github.com/ithewei/libhv/pull/490
17 (fetchpatch {
18 name = "gcc-13.patch";
19 url = "https://github.com/ithewei/libhv/commit/b3e61519fbdbbb956fed275c0a849ba5d4d6e45c.patch";
20 hash = "sha256-fuYI+B3qZkSAbLZc0p6/0fnqaHx6w9N9vhTEE2t6UUs=";
21 })
22 ];
23
24 nativeBuildInputs = [ cmake ];
25
26 buildInputs = [ curl openssl ] ++ lib.optional stdenv.isDarwin Security;
27
28 cmakeFlags = [
29 "-DENABLE_UDS=ON"
30 "-DWITH_MQTT=ON"
31 "-DWITH_CURL=ON"
32 "-DWITH_NGHTTP2=ON"
33 "-DWITH_OPENSSL=ON"
34 "-DWITH_KCP=ON"
35 ];
36
37 meta = with lib; {
38 description = "C/c++ network library for developing TCP/UDP/SSL/HTTP/WebSocket/MQTT client/server";
39 homepage = "https://github.com/ithewei/libhv";
40 license = licenses.bsd3;
41 maintainers = with maintainers; [ sikmir ];
42 platforms = platforms.unix;
43 };
44})