1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, pkg-config
6, openssl
7, zlib
8, zstd
9, icu
10, cyrus_sasl
11, snappy
12, darwin
13}:
14
15stdenv.mkDerivation rec {
16 pname = "mongoc";
17 version = "1.23.4";
18
19 src = fetchFromGitHub {
20 owner = "mongodb";
21 repo = "mongo-c-driver";
22 rev = "refs/tags/${version}";
23 hash = "sha256-jYEEWbm00V3zhzxH8jBkrj/+OC6CGjbh5qofNYmsdTk=";
24 };
25
26 postPatch = ''
27 substituteInPlace src/libbson/CMakeLists.txt src/libmongoc/CMakeLists.txt \
28 --replace "\\\''${prefix}/" ""
29 '';
30
31 nativeBuildInputs = [
32 cmake
33 pkg-config
34 ];
35
36 buildInputs = [
37 openssl
38 zlib
39 zstd
40 icu
41 cyrus_sasl
42 snappy
43 ] ++ lib.optionals stdenv.isDarwin [
44 darwin.apple_sdk.frameworks.Security
45 ];
46
47 cmakeFlags = [
48 "-DBUILD_VERSION=${version}"
49 "-DENABLE_UNINSTALL=OFF"
50 "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF"
51 ];
52
53 # remove forbidden reference to $TMPDIR
54 preFixup = ''
55 rm -rf src/{libmongoc,libbson}
56 '';
57
58 meta = with lib; {
59 broken = stdenv.isDarwin && stdenv.isx86_64;
60 description = "The official C client library for MongoDB";
61 homepage = "http://mongoc.org";
62 license = licenses.asl20;
63 mainProgram = "mongoc-stat";
64 maintainers = with maintainers; [ archer-65 ];
65 platforms = platforms.all;
66 };
67}