1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 cmake,
7 pkg-config,
8 mongoc,
9 openssl,
10}:
11
12stdenv.mkDerivation rec {
13 pname = "libmongocrypt";
14 version = "1.7.4";
15
16 src = fetchFromGitHub {
17 owner = "mongodb";
18 repo = "libmongocrypt";
19 rev = version;
20 hash = "sha256-I4KG2BHAovin9EaF8lNzJzucARvi0Qptz5Y9gTt3WkE=";
21 };
22
23 patches = [
24 # fix pkg-config files
25 # submitted upstream: https://github.com/mongodb/libmongocrypt/pull/634
26 (fetchpatch {
27 url = "https://github.com/mongodb/libmongocrypt/commit/5514cf0a366c4d0dc1b0f2a62201f0f1161054da.diff";
28 hash = "sha256-eMSn6MRnc3yKfU2u/Bg3juWiupDzY1DUGi1/HSRftIs=";
29 })
30 ];
31
32 nativeBuildInputs = [
33 cmake
34 pkg-config
35 ];
36
37 buildInputs = [
38 mongoc
39 openssl
40 ];
41
42 cmakeFlags = [
43 # all three of these are required to use system libbson
44 "-DUSE_SHARED_LIBBSON=ON"
45 "-DMONGOCRYPT_MONGOC_DIR=USE-SYSTEM"
46 "-DENABLE_ONLINE_TESTS=OFF"
47
48 # this pulls in a library we don't have
49 "-DMONGOCRYPT_ENABLE_DECIMAL128=OFF"
50
51 # this avoids a dependency on Python
52 "-DBUILD_VERSION=${version}"
53 ];
54
55 meta = with lib; {
56 description = "Required C library for client-side and queryable encryption in MongoDB";
57 homepage = "https://github.com/mongodb/libmongocrypt";
58 license = licenses.asl20;
59 platforms = platforms.unix;
60 };
61}