nixpkgs/pkgs/development/libraries/libmongocrypt/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

60 lines
1.4 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, cmake
, pkg-config
, mongoc
, openssl
, darwin
}:
stdenv.mkDerivation rec {
pname = "libmongocrypt";
version = "1.7.4";
src = fetchFromGitHub {
owner = "mongodb";
repo = pname;
rev = version;
hash = "sha256-I4KG2BHAovin9EaF8lNzJzucARvi0Qptz5Y9gTt3WkE=";
};
patches = [
# fix pkg-config files
# submitted upstream: https://github.com/mongodb/libmongocrypt/pull/634
(fetchpatch {
url = "https://github.com/mongodb/libmongocrypt/commit/5514cf0a366c4d0dc1b0f2a62201f0f1161054da.diff";
hash = "sha256-eMSn6MRnc3yKfU2u/Bg3juWiupDzY1DUGi1/HSRftIs=";
})
];
nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [
mongoc
openssl
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk_11_0.frameworks.Security
];
cmakeFlags = [
# all three of these are required to use system libbson
"-DUSE_SHARED_LIBBSON=ON"
"-DMONGOCRYPT_MONGOC_DIR=USE-SYSTEM"
"-DENABLE_ONLINE_TESTS=OFF"
# this pulls in a library we don't have
"-DMONGOCRYPT_ENABLE_DECIMAL128=OFF"
# this avoids a dependency on Python
"-DBUILD_VERSION=${version}"
];
meta = with lib; {
description = "Required C library for client-side and queryable encryption in MongoDB";
homepage = "https://github.com/mongodb/libmongocrypt";
license = licenses.asl20;
platforms = platforms.unix;
};
}