2022-10-21 18:38:19 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
2023-11-16 04:20:00 +00:00
|
|
|
, scons_3_1_2
|
2022-10-21 18:38:19 +00:00
|
|
|
, boost
|
|
|
|
, gperftools
|
|
|
|
, pcre-cpp
|
|
|
|
, snappy
|
|
|
|
, zlib
|
2023-02-02 18:25:31 +00:00
|
|
|
, yaml-cpp
|
2022-10-21 18:38:19 +00:00
|
|
|
, sasl
|
2024-01-25 14:12:00 +00:00
|
|
|
, net-snmp
|
|
|
|
, openldap
|
2022-10-21 18:38:19 +00:00
|
|
|
, openssl
|
|
|
|
, libpcap
|
|
|
|
, python3
|
|
|
|
, curl
|
|
|
|
, Security
|
|
|
|
, CoreFoundation
|
|
|
|
, cctools
|
|
|
|
, xz
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Note:
|
2022-10-21 18:38:19 +00:00
|
|
|
# The command line administrative tools are part of other packages:
|
|
|
|
# see pkgs.mongodb-tools and pkgs.mongosh.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
{ version, sha256, patches ? []
|
2021-01-15 22:18:51 +00:00
|
|
|
, license ? lib.licenses.sspl
|
2022-04-15 01:41:22 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2022-10-21 18:38:19 +00:00
|
|
|
variants =
|
2023-11-16 04:20:00 +00:00
|
|
|
if versionAtLeast version "6.0"
|
|
|
|
then rec {
|
2022-10-21 18:38:19 +00:00
|
|
|
python = scons.python.withPackages (ps: with ps; [
|
|
|
|
pyyaml
|
|
|
|
cheetah3
|
|
|
|
psutil
|
|
|
|
setuptools
|
|
|
|
packaging
|
|
|
|
pymongo
|
|
|
|
]);
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
scons = scons_3_1_2;
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
mozjsVersion = "60";
|
|
|
|
mozjsReplace = "defined(HAVE___SINCOS)";
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
}
|
|
|
|
else rec {
|
2022-10-21 18:38:19 +00:00
|
|
|
python = scons.python.withPackages (ps: with ps; [
|
|
|
|
pyyaml
|
|
|
|
cheetah3
|
|
|
|
psutil
|
|
|
|
setuptools
|
|
|
|
]);
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
scons = scons_3_1_2;
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
mozjsVersion = "60";
|
|
|
|
mozjsReplace = "defined(HAVE___SINCOS)";
|
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
system-libraries = [
|
|
|
|
"boost"
|
|
|
|
"pcre"
|
|
|
|
"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"
|
|
|
|
] ++ optionals stdenv.isLinux [ "tcmalloc" ];
|
2021-01-15 22:18:51 +00:00
|
|
|
inherit (lib) systems subtractLists;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
inherit version;
|
2020-08-20 17:08:02 +00:00
|
|
|
pname = "mongodb";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://fastdl.mongodb.org/src/mongodb-src-r${version}.tar.gz";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
nativeBuildInputs = [ variants.scons ]
|
2023-11-16 04:20:00 +00:00
|
|
|
++ lib.optionals (versionAtLeast version "4.4") [ xz ];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = [
|
|
|
|
boost
|
|
|
|
curl
|
|
|
|
gperftools
|
|
|
|
libpcap
|
2023-02-02 18:25:31 +00:00
|
|
|
yaml-cpp
|
2020-04-24 23:36:52 +00:00
|
|
|
openssl
|
2024-01-25 14:12:00 +00:00
|
|
|
openldap
|
2020-04-24 23:36:52 +00:00
|
|
|
pcre-cpp
|
2020-08-20 17:08:02 +00:00
|
|
|
variants.python
|
2020-04-24 23:36:52 +00:00
|
|
|
sasl
|
|
|
|
snappy
|
|
|
|
zlib
|
2024-02-07 01:22:34 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ]
|
|
|
|
++ lib.optionals stdenv.isLinux [ net-snmp ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# 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;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# fix environment variable reading
|
|
|
|
substituteInPlace SConstruct \
|
|
|
|
--replace "env = Environment(" "env = Environment(ENV = os.environ,"
|
2022-12-28 21:21:41 +00:00
|
|
|
'' + lib.optionalString (versionAtLeast version "4.4") ''
|
2022-09-14 18:05:37 +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>'
|
2023-04-12 12:48:02 +00:00
|
|
|
'' + lib.optionalString (versionOlder version "5.0") ''
|
|
|
|
# remove -march overriding, we know better.
|
|
|
|
sed -i 's/env.Append.*-march=.*$/pass/' SConstruct
|
2022-12-28 21:21:41 +00:00
|
|
|
'' + lib.optionalString (stdenv.isDarwin && versionOlder version "6.0") ''
|
2020-08-20 17:08:02 +00:00
|
|
|
substituteInPlace src/third_party/mozjs-${variants.mozjsVersion}/extract/js/src/jsmath.cpp --replace '${variants.mozjsReplace}' 0
|
2022-09-14 18:05:37 +00:00
|
|
|
'' + lib.optionalString (stdenv.isDarwin && versionOlder version "3.6") ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace src/third_party/s2/s1angle.cc --replace drem remainder
|
|
|
|
substituteInPlace src/third_party/s2/s1interval.cc --replace drem remainder
|
|
|
|
substituteInPlace src/third_party/s2/s2cap.cc --replace drem remainder
|
|
|
|
substituteInPlace src/third_party/s2/s2latlng.cc --replace drem remainder
|
|
|
|
substituteInPlace src/third_party/s2/s2latlngrect.cc --replace drem remainder
|
2021-01-15 22:18:51 +00:00
|
|
|
'' + lib.optionalString stdenv.isi686 ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# don't fail by default on i686
|
|
|
|
substituteInPlace src/mongo/db/storage/storage_options.h \
|
|
|
|
--replace 'engine("wiredTiger")' 'engine("mmapv1")'
|
|
|
|
'';
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang
|
2020-04-24 23:36:52 +00:00
|
|
|
"-Wno-unused-command-line-argument";
|
|
|
|
|
|
|
|
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
|
2022-04-15 01:41:22 +00:00
|
|
|
] ++ lib.optionals (versionAtLeast version "4.4") [ "--link-model=static" ]
|
2023-11-16 04:20:00 +00:00
|
|
|
++ map (lib: "--use-system-${lib}") system-libraries;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
# This seems to fix mongodb not able to find OpenSSL's crypto.h during build
|
|
|
|
hardeningDisable = [ "fortify3" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preBuild = ''
|
|
|
|
sconsFlags+=" CC=$CC"
|
|
|
|
sconsFlags+=" CXX=$CXX"
|
|
|
|
'' + optionalString stdenv.isAarch64 ''
|
|
|
|
sconsFlags+=" CCFLAGS='-march=armv8-a+crc'"
|
|
|
|
'';
|
|
|
|
|
|
|
|
preInstall = ''
|
|
|
|
mkdir -p "$out/lib"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
rm -f "$out/bin/install_compass" || true
|
|
|
|
'';
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
"$out/bin/mongo" --version
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
installTargets =
|
|
|
|
if (versionAtLeast version "6.0") then "install-devcore"
|
|
|
|
else if (versionAtLeast version "4.4") then "install-core"
|
|
|
|
else "install";
|
2022-04-15 01:41:22 +00:00
|
|
|
|
|
|
|
prefixKey = if (versionAtLeast version "4.4") then "DESTDIR=" else "--prefix=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
hardeningEnable = [ "pie" ];
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "A scalable, high-performance, open source NoSQL database";
|
|
|
|
homepage = "http://www.mongodb.org";
|
|
|
|
inherit license;
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
maintainers = with maintainers; [ bluescreen303 offline ];
|
2022-12-28 21:21:41 +00:00
|
|
|
platforms = subtractLists systems.doubles.i686 systems.doubles.unix;
|
2023-03-27 19:17:25 +00:00
|
|
|
broken = (versionOlder version "6.0" && stdenv.system == "aarch64-darwin");
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|