nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 asio,
7 boost,
8 expected-lite,
9 fmt,
10 llhttp,
11 openssl,
12 pcre2,
13 zlib,
14 catch2_3,
15 # Build with the asio library bundled in boost instead of the standalone asio package.
16 with_boost_asio ? false,
17}:
18
19assert with_boost_asio -> boost != null;
20assert !with_boost_asio -> asio != null;
21
22stdenv.mkDerivation (finalAttrs: {
23 pname = "restinio";
24 version = "0.7.9";
25
26 src = fetchFromGitHub {
27 owner = "Stiffstream";
28 repo = "restinio";
29 tag = "v${finalAttrs.version}";
30 hash = "sha256-ZosfTdi/u8/sHDf6UYP49ZEkTtT9FkVCazff/rMNbLA=";
31 };
32
33 # https://www.github.com/Stiffstream/restinio/issues/230
34 # > string sub-command JSON failed parsing json string: * Line 1, Column 1
35 # > Syntax error: value, object or array expected.
36 postPatch = ''
37 substituteInPlace dev/test/CMakeLists.txt \
38 --replace-fail "add_subdirectory(metaprogramming)" ""
39 '';
40
41 strictDeps = true;
42
43 nativeBuildInputs = [ cmake ];
44
45 propagatedBuildInputs = [
46 expected-lite
47 fmt
48 openssl
49 pcre2
50 zlib
51 ]
52 ++ (
53 if with_boost_asio then
54 [
55 boost
56 ]
57 else
58 [
59 asio
60 ]
61 );
62
63 buildInputs = [
64 catch2_3
65 llhttp
66 ];
67
68 cmakeDir = "../dev";
69 cmakeFlags = [
70 "-DCMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE=PRE_TEST"
71 "-DRESTINIO_TEST=ON"
72 "-DRESTINIO_SAMPLE=OFF"
73 "-DRESTINIO_BENCHMARK=OFF"
74 "-DRESTINIO_WITH_SOBJECTIZER=OFF"
75 "-DRESTINIO_ASIO_SOURCE=${if with_boost_asio then "boost" else "standalone"}"
76 "-DRESTINIO_DEP_EXPECTED_LITE=find"
77 "-DRESTINIO_DEP_FMT=find"
78 "-DRESTINIO_DEP_LLHTTP=system"
79 "-DRESTINIO_DEP_CATCH2=find"
80 ];
81
82 doCheck = true;
83 enableParallelChecking = false;
84 __darwinAllowLocalNetworking = true;
85 preCheck =
86 let
87 disabledTests =
88 [ ]
89 ++ lib.optionals stdenv.hostPlatform.isDarwin [
90 # Tests that fail with error: 'unable to write: Operation not permitted'
91 "HTTP echo server"
92 "single_thread_connection_limiter"
93 "simple sendfile"
94 "simple sendfile with std::filesystem::path"
95 "sendfile the same file several times"
96 "sendfile 2 files"
97 "sendfile offsets_and_size"
98 "sendfile chunks"
99 "sendfile with partially-read response"
100 ];
101 excludeRegex = "^(${builtins.concatStringsSep "|" disabledTests})";
102 in
103 lib.optionalString (builtins.length disabledTests != 0) ''
104 checkFlagsArray+=(ARGS="--exclude-regex '${excludeRegex}'")
105 '';
106
107 meta = {
108 description = "Cross-platform, efficient, customizable, and robust asynchronous HTTP(S)/WebSocket server C++ library";
109 homepage = "https://github.com/Stiffstream/restinio";
110 changelog = "https://github.com/Stiffstream/restinio/releases/tag/${finalAttrs.src.rev}";
111 license = lib.licenses.bsd3;
112 platforms = lib.platforms.all;
113 maintainers = with lib.maintainers; [ tobim ];
114 };
115})