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