nixpkgs/pkgs/servers/nosql/mongodb/mongodb.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

179 lines
4.3 KiB
Nix
Raw Permalink Normal View History

2022-09-09 19:13:25 +00:00
{ lib
, stdenv
, fetchFromGitHub
2024-02-02 12:34:06 +00:00
, buildPackages
2022-09-09 19:13:25 +00:00
, boost
, gperftools
2024-07-14 20:16:23 +00:00
, pcre2
2022-09-09 19:13:25 +00:00
, pcre-cpp
, snappy
, zlib
, yaml-cpp
2022-09-09 19:13:25 +00:00
, sasl
, net-snmp
, openldap
2022-09-09 19:13:25 +00:00
, openssl
, libpcap
, curl
, Security
, CoreFoundation
, cctools
, xz
}:
2014-04-26 18:13:51 +00:00
2016-01-27 02:48:57 +00:00
# Note:
# The command line administrative tools are part of other packages:
# see pkgs.mongodb-tools and pkgs.mongosh.
2016-01-27 02:48:57 +00:00
{ version, sha256, patches ? []
2021-01-15 07:07:56 +00:00
, license ? lib.licenses.sspl
, avxSupport ? stdenv.hostPlatform.avxSupport
, passthru ? {}
2022-03-02 10:55:53 +00:00
}:
let
2024-09-01 20:15:21 +00:00
scons = buildPackages.scons;
python = scons.python.withPackages (ps: with ps; [
pyyaml
cheetah3
psutil
setuptools
2024-09-01 20:15:21 +00:00
distutils
packaging
pymongo
]);
system-libraries = [
"boost"
"snappy"
"yaml"
"zlib"
#"asio" -- XXX use package?
#"stemmer" -- not nice to package yet (no versioning, no makefile, no shared libs).
#"valgrind" -- mongodb only requires valgrind.h, which is vendored in the source.
#"wiredtiger"
2024-07-14 20:16:23 +00:00
] ++ lib.optionals stdenv.hostPlatform.isLinux [ "tcmalloc" ]
++ lib.optionals (lib.versionOlder version "7.0") [
"pcre"
]
++ lib.optionals (lib.versionAtLeast version "7.0") [
"pcre2"
];
2021-01-15 07:07:56 +00:00
inherit (lib) systems subtractLists;
in stdenv.mkDerivation rec {
inherit version passthru;
2020-04-03 23:08:37 +00:00
pname = "mongodb";
src = fetchFromGitHub {
owner = "mongodb";
repo = "mongo";
rev = "r${version}";
inherit sha256;
};
2024-02-02 12:34:06 +00:00
nativeBuildInputs = [
scons
python
] ++ lib.optional stdenv.hostPlatform.isLinux net-snmp;
2022-03-02 10:55:53 +00:00
buildInputs = [
boost
curl
gperftools
libpcap
yaml-cpp
openssl
openldap
2024-07-14 20:16:23 +00:00
pcre2
pcre-cpp
sasl
snappy
zlib
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ Security CoreFoundation cctools ]
2024-02-02 12:34:06 +00:00
++ lib.optional stdenv.hostPlatform.isLinux net-snmp
2024-04-11 10:06:24 +00:00
++ [ xz ];
# MongoDB keeps track of its build parameters, which tricks nix into
# keeping dependencies to build inputs in the final output.
# We remove the build flags from buildInfo data.
inherit patches;
2016-01-27 02:48:57 +00:00
postPatch = ''
2014-09-14 18:20:10 +00:00
# fix environment variable reading
substituteInPlace SConstruct \
2015-04-08 21:41:17 +00:00
--replace "env = Environment(" "env = Environment(ENV = os.environ,"
2024-04-11 10:06:24 +00:00
'' + ''
# Fix debug gcc 11 and clang 12 builds on Fedora
# https://github.com/mongodb/mongo/commit/e78b2bf6eaa0c43bd76dbb841add167b443d2bb0.patch
substituteInPlace src/mongo/db/query/plan_summary_stats.h --replace '#include <string>' '#include <optional>
#include <string>'
substituteInPlace src/mongo/db/exec/plan_stats.h --replace '#include <string>' '#include <optional>
#include <string>'
'' + lib.optionalString (!avxSupport) ''
substituteInPlace SConstruct \
--replace-fail "default=['+sandybridge']," 'default=[],'
'';
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang
"-Wno-unused-command-line-argument";
2017-11-01 13:13:34 +00:00
sconsFlags = [
"--release"
"--ssl"
#"--rocksdb" # Don't have this packaged yet
"--wiredtiger=on"
"--js-engine=mozjs"
"--use-sasl-client"
"--disable-warnings-as-errors"
"VARIANT_DIR=nixos" # Needed so we don't produce argument lists that are too long for gcc / ld
2024-04-11 10:06:24 +00:00
"--link-model=static"
"MONGO_VERSION=${version}"
2024-04-11 10:06:24 +00:00
]
2023-10-28 20:31:11 +00:00
++ map (lib: "--use-system-${lib}") system-libraries;
# This seems to fix mongodb not able to find OpenSSL's crypto.h during build
hardeningDisable = [ "fortify3" ];
preBuild = ''
sconsFlags+=" CC=$CC"
sconsFlags+=" CXX=$CXX"
2024-06-30 10:56:02 +00:00
'' + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
2024-02-02 12:34:06 +00:00
sconsFlags+=" AR=$AR"
2024-06-30 10:56:02 +00:00
'' + lib.optionalString stdenv.hostPlatform.isAarch64 ''
2019-07-28 11:54:50 +00:00
sconsFlags+=" CCFLAGS='-march=armv8-a+crc'"
'';
preInstall = ''
mkdir -p "$out/lib"
'';
postInstall = ''
rm -f "$out/bin/install_compass" || true
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
"$out/bin/mongo" --version
runHook postInstallCheck
'';
installTargets = "install-devcore";
2022-03-02 10:55:53 +00:00
2024-04-11 10:06:24 +00:00
prefixKey = "DESTDIR=";
2015-04-08 21:59:35 +00:00
enableParallelBuilding = true;
hardeningEnable = [ "pie" ];
2016-02-27 00:48:49 +00:00
2024-06-30 10:56:02 +00:00
meta = with lib; {
description = "Scalable, high-performance, open source NoSQL database";
homepage = "http://www.mongodb.org";
inherit license;
maintainers = with maintainers; [ bluescreen303 offline ];
2022-09-14 23:30:54 +00:00
platforms = subtractLists systems.doubles.i686 systems.doubles.unix;
};
}