about summary refs log tree commit diff
path: root/pkgs/development/libraries/mongoc/default.nix
blob: 905d8330fe4d46bbae3a789a4160671e303c7a4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
  lib,
  stdenv,
  fetchzip,
  cmake,
  pkg-config,
  perl,
  openssl,
  zlib,
  cyrus_sasl,
  libbson,
  snappy,
  darwin,
}:
let
  inherit (darwin.apple_sdk.frameworks) Security;
in
stdenv.mkDerivation rec {
  pname = "mongoc";
  version = "1.23.2";

  src = fetchzip {
    url = "https://github.com/mongodb/mongo-c-driver/releases/download/${version}/mongo-c-driver-${version}.tar.gz";
    sha256 = "08v7xc5m86apd338swd8g83ccvd6ni75xbdhqqwkrjbznljf8fjf";
  };

  # https://github.com/NixOS/nixpkgs/issues/25585
  preFixup = ''rm -rf "$(pwd)" '';
  # https://github.com/mongodb/mongo-c-driver/pull/1157
  # related:
  # https://github.com/NixOS/nixpkgs/issues/144170
  # mongoc's cmake incorrectly injects a prefix to library paths, breaking Nix. This removes the prefix from paths.
  postPatch = ''
    substituteInPlace src/libmongoc/CMakeLists.txt \
      --replace "\\\''${prefix}/" ""
    substituteInPlace src/libbson/CMakeLists.txt \
      --replace "\\\''${prefix}/" ""
  '';

  nativeBuildInputs = [cmake pkg-config perl];
  buildInputs = [openssl zlib cyrus_sasl] ++ lib.optionals stdenv.isDarwin [Security];
  propagatedBuildInputs = [libbson snappy];

  # -DMONGOC_TEST_USE_CRYPT_SHARED=OFF
  # The `mongodl.py` script is causing issues, and you also need to disabled sandboxing for it. However, it is used only to run some tests.
  # https://www.mongodb.com/community/forums/t/problem-downloading-crypt-shared-when-installing-the-mongodb-c-driver/189370
  cmakeFlags = ["-DCMAKE_BUILD_TYPE=Release" "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF" "-DMONGOC_TEST_USE_CRYPT_SHARED=OFF"];

  enableParallelBuilding = true;

  meta = with lib; {
    broken = stdenv.isDarwin && stdenv.isx86_64;
    description = "The official C client library for MongoDB";
    homepage = "http://mongoc.org";
    license = licenses.asl20;
    mainProgram = "mongoc-stat";
    maintainers = with maintainers; [archer-65];
    platforms = platforms.all;
  };
}