about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/drogon
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/drogon')
-rw-r--r--nixpkgs/pkgs/development/libraries/drogon/default.nix67
-rw-r--r--nixpkgs/pkgs/development/libraries/drogon/fix_find_package.patch13
2 files changed, 80 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/drogon/default.nix b/nixpkgs/pkgs/development/libraries/drogon/default.nix
new file mode 100644
index 000000000000..a82759ba3e57
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/drogon/default.nix
@@ -0,0 +1,67 @@
+{ stdenv, fetchFromGitHub, cmake, jsoncpp, libossp_uuid, zlib, lib, fetchpatch
+# optional but of negligible size
+, openssl, brotli, c-ares
+# optional databases
+, sqliteSupport ? true, sqlite
+, postgresSupport ? false, postgresql
+, redisSupport ? false, hiredis
+, mysqlSupport ? false, libmysqlclient, mariadb }:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "drogon";
+  version = "1.8.7";
+
+  src = fetchFromGitHub {
+    owner = "drogonframework";
+    repo = "drogon";
+    rev = "v${finalAttrs.version}";
+    sha256 = "sha256-lKV4dRIIkCn/qW8DyqDRHADh0tW0/ocf/29ox9aC0Yo=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  cmakeFlags = [
+    "-DBUILD_TESTING=${if finalAttrs.finalPackage.doInstallCheck then "ON" else "OFF"}"
+    "-DBUILD_EXAMPLES=OFF"
+  ];
+
+  propagatedBuildInputs = [
+    jsoncpp
+    libossp_uuid
+    zlib
+    openssl
+    brotli
+    c-ares
+  ] ++ lib.optional sqliteSupport sqlite
+    ++ lib.optional postgresSupport postgresql
+    ++ lib.optional redisSupport hiredis
+    # drogon uses mariadb for mysql (see https://github.com/drogonframework/drogon/wiki/ENG-02-Installation#Library-Dependencies)
+    ++ lib.optionals mysqlSupport [ libmysqlclient mariadb ];
+
+  patches = [
+    # this part of the test would normally fail because it attempts to configure a CMake project that uses find_package on itself
+    # this patch makes drogon and trantor visible to the test
+    ./fix_find_package.patch
+  ];
+
+  # modifying PATH here makes drogon_ctl visible to the test
+  installCheckPhase = ''
+    (
+      cd ..
+      PATH=$PATH:$out/bin $SHELL test.sh
+    )
+  '';
+
+  # this excludes you, pkgsStatic (cmake wants to run built binaries
+  # in the buildPhase)
+  doInstallCheck = stdenv.buildPlatform == stdenv.hostPlatform;
+
+  meta = with lib; {
+    homepage = "https://github.com/drogonframework/drogon";
+    description = "C++14/17 based HTTP web application framework";
+    license = licenses.mit;
+    maintainers = with maintainers; [ urlordjames ];
+    platforms = platforms.all;
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/drogon/fix_find_package.patch b/nixpkgs/pkgs/development/libraries/drogon/fix_find_package.patch
new file mode 100644
index 000000000000..b76dbfe48830
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/drogon/fix_find_package.patch
@@ -0,0 +1,13 @@
+diff --git a/test.sh b/test.sh
+index f017b9a..027031e 100755
+--- a/test.sh
++++ b/test.sh
+@@ -135,7 +135,7 @@ if [ $os = "windows" ]; then
+   conan install $src_dir -s compiler="Visual Studio" -s compiler.version=16 -sbuild_type=Debug -g cmake_paths
+   cmake_gen="$cmake_gen -DCMAKE_TOOLCHAIN_FILE=conan_paths.cmake -DCMAKE_INSTALL_PREFIX=$src_dir/install"
+ fi
+-cmake .. $cmake_gen
++cmake .. $cmake_gen -DDrogon_DIR=$out/lib/cmake/Drogon -DTrantor_DIR=$out/lib/cmake/Trantor
+ 
+ if [ $? -ne 0 ]; then
+     echo "Failed to run CMake for example project"