2022-09-09 19:13:25 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2024-05-07 17:43:04 +00:00
|
|
|
, 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
|
2023-01-29 14:44:19 +00:00
|
|
|
, yaml-cpp
|
2022-09-09 19:13:25 +00:00
|
|
|
, sasl
|
2024-01-20 22:59:13 +00:00
|
|
|
, 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:
|
2022-09-09 19:16:16 +00:00
|
|
|
# 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
|
|
|
|
2020-04-21 15:34:13 +00:00
|
|
|
{ version, sha256, patches ? []
|
2021-01-15 07:07:56 +00:00
|
|
|
, license ? lib.licenses.sspl
|
2024-03-27 22:08:12 +00:00
|
|
|
, avxSupport ? stdenv.hostPlatform.avxSupport
|
2024-08-17 22:29:43 +00:00
|
|
|
, passthru ? {}
|
2022-03-02 10:55:53 +00:00
|
|
|
}:
|
2019-05-31 12:14:14 +00:00
|
|
|
|
|
|
|
let
|
2024-09-01 20:15:21 +00:00
|
|
|
scons = buildPackages.scons;
|
2024-02-02 12:31:51 +00:00
|
|
|
python = scons.python.withPackages (ps: with ps; [
|
|
|
|
pyyaml
|
|
|
|
cheetah3
|
|
|
|
psutil
|
|
|
|
setuptools
|
2024-09-01 20:15:21 +00:00
|
|
|
distutils
|
2024-02-02 12:31:51 +00:00
|
|
|
packaging
|
|
|
|
pymongo
|
|
|
|
]);
|
|
|
|
|
2019-05-31 12:14:14 +00:00
|
|
|
system-libraries = [
|
|
|
|
"boost"
|
|
|
|
"snappy"
|
2019-08-04 06:25:56 +00:00
|
|
|
"yaml"
|
2019-05-31 12:14:14 +00:00
|
|
|
"zlib"
|
2019-08-04 06:25:56 +00:00
|
|
|
#"asio" -- XXX use package?
|
2019-05-31 12:14:14 +00:00
|
|
|
#"stemmer" -- not nice to package yet (no versioning, no makefile, no shared libs).
|
2019-08-04 06:25:56 +00:00
|
|
|
#"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;
|
2019-05-31 12:14:14 +00:00
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
2024-08-17 22:29:43 +00:00
|
|
|
inherit version passthru;
|
2020-04-03 23:08:37 +00:00
|
|
|
pname = "mongodb";
|
2012-01-18 20:32:41 +00:00
|
|
|
|
2024-05-07 17:43:04 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mongodb";
|
|
|
|
repo = "mongo";
|
|
|
|
rev = "r${version}";
|
2019-05-31 12:14:14 +00:00
|
|
|
inherit sha256;
|
2012-01-18 20:32:41 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2018-11-12 02:52:07 +00:00
|
|
|
buildInputs = [
|
2019-08-04 06:25:56 +00:00
|
|
|
boost
|
|
|
|
curl
|
|
|
|
gperftools
|
|
|
|
libpcap
|
2023-01-29 14:44:19 +00:00
|
|
|
yaml-cpp
|
2020-02-25 14:11:53 +00:00
|
|
|
openssl
|
2024-01-20 22:59:13 +00:00
|
|
|
openldap
|
2024-07-14 20:16:23 +00:00
|
|
|
pcre2
|
2019-08-04 06:25:56 +00:00
|
|
|
pcre-cpp
|
|
|
|
sasl
|
|
|
|
snappy
|
|
|
|
zlib
|
2024-01-28 20:05:43 +00:00
|
|
|
] ++ 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 ];
|
2012-01-18 20:32:41 +00:00
|
|
|
|
2019-05-31 12:14:14 +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;
|
2016-01-27 02:48:57 +00:00
|
|
|
|
2012-09-09 15:25:59 +00:00
|
|
|
postPatch = ''
|
2014-09-14 18:20:10 +00:00
|
|
|
# fix environment variable reading
|
2013-05-12 16:21:13 +00:00
|
|
|
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
|
|
|
'' + ''
|
2022-07-20 20:59: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>'
|
2024-03-27 22:08:12 +00:00
|
|
|
'' + lib.optionalString (!avxSupport) ''
|
|
|
|
substituteInPlace SConstruct \
|
|
|
|
--replace-fail "default=['+sandybridge']," 'default=[],'
|
2012-01-18 20:32:41 +00:00
|
|
|
'';
|
|
|
|
|
2023-02-19 19:23:32 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang
|
2019-05-31 12:14:14 +00:00
|
|
|
"-Wno-unused-command-line-argument";
|
2017-11-01 13:13:34 +00:00
|
|
|
|
2018-11-12 02:52:07 +00:00
|
|
|
sconsFlags = [
|
|
|
|
"--release"
|
|
|
|
"--ssl"
|
|
|
|
#"--rocksdb" # Don't have this packaged yet
|
2019-08-04 03:09:49 +00:00
|
|
|
"--wiredtiger=on"
|
2018-11-12 02:52:07 +00:00
|
|
|
"--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"
|
2024-05-07 17:43:04 +00:00
|
|
|
"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;
|
2018-11-12 02:52:07 +00:00
|
|
|
|
2023-08-02 14:17:45 +00:00
|
|
|
# This seems to fix mongodb not able to find OpenSSL's crypto.h during build
|
|
|
|
hardeningDisable = [ "fortify3" ];
|
|
|
|
|
2018-11-12 02:52:07 +00:00
|
|
|
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'"
|
2012-01-18 20:32:41 +00:00
|
|
|
'';
|
|
|
|
|
2018-11-12 02:52:07 +00:00
|
|
|
preInstall = ''
|
2019-05-31 12:14:14 +00:00
|
|
|
mkdir -p "$out/lib"
|
2012-01-18 20:32:41 +00:00
|
|
|
'';
|
2018-05-03 07:42:24 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
2019-05-31 12:14:14 +00:00
|
|
|
rm -f "$out/bin/install_compass" || true
|
2018-05-03 07:42:24 +00:00
|
|
|
'';
|
|
|
|
|
2020-07-11 09:07:18 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
"$out/bin/mongo" --version
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2024-10-01 00:27:51 +00:00
|
|
|
installTargets = "install-devcore";
|
2022-03-02 10:55:53 +00:00
|
|
|
|
2024-04-11 10:06:24 +00:00
|
|
|
prefixKey = "DESTDIR=";
|
2012-01-18 20:32:41 +00:00
|
|
|
|
2015-04-08 21:59:35 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningEnable = [ "pie" ];
|
2016-02-27 00:48:49 +00:00
|
|
|
|
2024-06-30 10:56:02 +00:00
|
|
|
meta = with lib; {
|
2016-06-20 10:53:46 +00:00
|
|
|
description = "Scalable, high-performance, open source NoSQL database";
|
2019-05-31 12:14:14 +00:00
|
|
|
homepage = "http://www.mongodb.org";
|
2020-04-21 15:34:13 +00:00
|
|
|
inherit license;
|
2012-01-18 20:32:41 +00:00
|
|
|
|
2023-09-29 22:29:36 +00:00
|
|
|
maintainers = with maintainers; [ bluescreen303 offline ];
|
2022-09-14 23:30:54 +00:00
|
|
|
platforms = subtractLists systems.doubles.i686 systems.doubles.unix;
|
2012-01-18 20:32:41 +00:00
|
|
|
};
|
|
|
|
}
|