1{ stdenv, fetchFromGitHub, cmake, jsoncpp, libossp_uuid, zlib, lib, fetchpatch
2# optional but of negligible size
3, openssl, brotli, c-ares
4# optional databases
5, sqliteSupport ? true, sqlite
6, postgresSupport ? false, postgresql
7, redisSupport ? false, hiredis
8, mysqlSupport ? false, libmysqlclient, mariadb }:
9
10stdenv.mkDerivation (finalAttrs: {
11 pname = "drogon";
12 version = "1.9.0";
13
14 src = fetchFromGitHub {
15 owner = "drogonframework";
16 repo = "drogon";
17 rev = "v${finalAttrs.version}";
18 sha256 = "sha256-KZRW/ra84RegCCT6J0k+N7XqZF+xW+Ecq2TVdPZnM7M=";
19 fetchSubmodules = true;
20 };
21
22 nativeBuildInputs = [ cmake ];
23
24 cmakeFlags = [
25 "-DBUILD_TESTING=${if finalAttrs.finalPackage.doInstallCheck then "ON" else "OFF"}"
26 "-DBUILD_EXAMPLES=OFF"
27 ];
28
29 propagatedBuildInputs = [
30 jsoncpp
31 libossp_uuid
32 zlib
33 openssl
34 brotli
35 c-ares
36 ] ++ lib.optional sqliteSupport sqlite
37 ++ lib.optional postgresSupport postgresql
38 ++ lib.optional redisSupport hiredis
39 # drogon uses mariadb for mysql (see https://github.com/drogonframework/drogon/wiki/ENG-02-Installation#Library-Dependencies)
40 ++ lib.optionals mysqlSupport [ libmysqlclient mariadb ];
41
42 patches = [
43 # this part of the test would normally fail because it attempts to configure a CMake project that uses find_package on itself
44 # this patch makes drogon and trantor visible to the test
45 ./fix_find_package.patch
46 ];
47
48 # modifying PATH here makes drogon_ctl visible to the test
49 installCheckPhase = ''
50 (
51 cd ..
52 PATH=$PATH:$out/bin $SHELL test.sh
53 )
54 '';
55
56 # this excludes you, pkgsStatic (cmake wants to run built binaries
57 # in the buildPhase)
58 doInstallCheck = stdenv.buildPlatform == stdenv.hostPlatform;
59
60 meta = with lib; {
61 homepage = "https://github.com/drogonframework/drogon";
62 description = "C++14/17 based HTTP web application framework";
63 license = licenses.mit;
64 maintainers = with maintainers; [ urlordjames ];
65 platforms = platforms.all;
66 };
67})