Merge pull request #233916 from NickCao/mongo

mongoc: rework packaging

authored by Weijia Wang and committed by GitHub 723c6080 6a065184

+44 -37
+44 -37
pkgs/development/libraries/mongoc/default.nix
··· 1 - { 2 - lib, 3 - stdenv, 4 - fetchzip, 5 - cmake, 6 - pkg-config, 7 - perl, 8 - openssl, 9 - zlib, 10 - cyrus_sasl, 11 - libbson, 12 - snappy, 13 - darwin, 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 14 13 }: 15 - let 16 - inherit (darwin.apple_sdk.frameworks) Security; 17 - in 14 + 18 15 stdenv.mkDerivation rec { 19 16 pname = "mongoc"; 20 17 version = "1.23.4"; 21 18 22 - src = fetchzip { 23 - url = "https://github.com/mongodb/mongo-c-driver/releases/download/${version}/mongo-c-driver-${version}.tar.gz"; 24 - sha256 = "sha256-mJBaRaX0hphvMdTII79DVn1g2uBmpRlObMiJ673Ijpw="; 19 + src = fetchFromGitHub { 20 + owner = "mongodb"; 21 + repo = "mongo-c-driver"; 22 + rev = "refs/tags/${version}"; 23 + hash = "sha256-jYEEWbm00V3zhzxH8jBkrj/+OC6CGjbh5qofNYmsdTk="; 25 24 }; 26 25 27 - # https://github.com/NixOS/nixpkgs/issues/25585 28 - preFixup = ''rm -rf "$(pwd)" ''; 29 - # https://github.com/mongodb/mongo-c-driver/pull/1157 30 - # related: 31 - # https://github.com/NixOS/nixpkgs/issues/144170 32 - # mongoc's cmake incorrectly injects a prefix to library paths, breaking Nix. This removes the prefix from paths. 33 26 postPatch = '' 34 - substituteInPlace src/libmongoc/CMakeLists.txt \ 35 - --replace "\\\''${prefix}/" "" 36 - substituteInPlace src/libbson/CMakeLists.txt \ 27 + substituteInPlace src/libbson/CMakeLists.txt src/libmongoc/CMakeLists.txt \ 37 28 --replace "\\\''${prefix}/" "" 38 29 ''; 39 30 40 - nativeBuildInputs = [cmake pkg-config perl]; 41 - buildInputs = [openssl zlib cyrus_sasl] ++ lib.optionals stdenv.isDarwin [Security]; 42 - propagatedBuildInputs = [libbson snappy]; 31 + nativeBuildInputs = [ 32 + cmake 33 + pkg-config 34 + ]; 43 35 44 - # -DMONGOC_TEST_USE_CRYPT_SHARED=OFF 45 - # 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. 46 - # https://www.mongodb.com/community/forums/t/problem-downloading-crypt-shared-when-installing-the-mongodb-c-driver/189370 47 - cmakeFlags = ["-DCMAKE_BUILD_TYPE=Release" "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF" "-DMONGOC_TEST_USE_CRYPT_SHARED=OFF"]; 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 + ]; 48 46 49 - enableParallelBuilding = true; 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 + ''; 50 57 51 58 meta = with lib; { 52 59 broken = stdenv.isDarwin && stdenv.isx86_64; ··· 54 61 homepage = "http://mongoc.org"; 55 62 license = licenses.asl20; 56 63 mainProgram = "mongoc-stat"; 57 - maintainers = with maintainers; [archer-65]; 64 + maintainers = with maintainers; [ archer-65 ]; 58 65 platforms = platforms.all; 59 66 }; 60 67 }