nixpkgs/pkgs/development/libraries/mongocxx/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

61 lines
1.4 KiB
Nix

{ lib
, pkgs
, fetchFromGitHub
, mongoc
, openssl
, cyrus_sasl
, cmake
, validatePkgConfig
, testers
, darwin
}:
let stdenv = if pkgs.stdenv.hostPlatform.isDarwin then darwin.apple_sdk_11_0.stdenv else pkgs.stdenv; in
stdenv.mkDerivation (finalAttrs: {
pname = "mongocxx";
version = "3.10.2";
src = fetchFromGitHub {
owner = "mongodb";
repo = "mongo-cxx-driver";
rev = "refs/tags/r${finalAttrs.version}";
hash = "sha256-nGLE0vyCe3PaNJf3duXdBfAhTdRvdeQ+OCwcaSDxi5Y=";
};
postPatch = ''
substituteInPlace src/bsoncxx/cmake/libbsoncxx.pc.in \
src/mongocxx/cmake/libmongocxx.pc.in \
--replace "\''${prefix}/" ""
'';
nativeBuildInputs = [
cmake
validatePkgConfig
];
buildInputs = [
mongoc
openssl
cyrus_sasl
] ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.frameworks.Security;
cmakeFlags = [
"-DCMAKE_CXX_STANDARD=20"
"-DBUILD_VERSION=${finalAttrs.version}"
"-DENABLE_UNINSTALL=OFF"
];
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
meta = with lib; {
description = "Official C++ client library for MongoDB";
homepage = "http://mongocxx.org";
license = licenses.asl20;
maintainers = with maintainers; [ adriandole vcele ];
pkgConfigModules = [ "libmongocxx" "libbsoncxx" ];
platforms = platforms.all;
badPlatforms = [ "x86_64-darwin" ]; # needs sdk >= 10.14
};
})