diff options
Diffstat (limited to 'nixpkgs/pkgs/servers/nosql/mongodb')
11 files changed, 642 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/4.4.nix b/nixpkgs/pkgs/servers/nosql/mongodb/4.4.nix new file mode 100644 index 000000000000..933e9136aee0 --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/4.4.nix @@ -0,0 +1,20 @@ +{ stdenv, callPackage, lib, fetchpatch, sasl, boost, Security, CoreFoundation, cctools }: + +let + buildMongoDB = callPackage ./mongodb.nix { + inherit sasl boost Security CoreFoundation cctools; + }; +in +buildMongoDB { + version = "4.4.28"; + sha256 = "sha256-aq4dJl2FOTOhQ3bzVj0L/0CE3obE7lCx2ecjGNYC8X4="; + patches = [ + ./forget-build-dependencies-4-4.patch + ./fix-build-with-boost-1.79-4_4.patch + (fetchpatch { + name = "mongodb-4.4.15-adjust-the-cache-alignment-assumptions.patch"; + url = "https://aur.archlinux.org/cgit/aur.git/plain/mongodb-4.4.15-adjust-cache-alignment-assumptions.patch.arm64?h=mongodb44"; + sha256 = "Ah4zdSFgXUJ/HSN8VRLJqDpNy3CjMCBnRqlpALXzx+g="; + }) + ] ++ lib.optionals stdenv.isDarwin [ ./asio-no-experimental-string-view-4-4.patch ]; +} diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/5.0.nix b/nixpkgs/pkgs/servers/nosql/mongodb/5.0.nix new file mode 100644 index 000000000000..2a26cb94eb16 --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/5.0.nix @@ -0,0 +1,28 @@ +{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }: + +let + buildMongoDB = callPackage ./mongodb.nix { + inherit sasl boost Security CoreFoundation cctools; + }; + variants = if stdenv.isLinux then + { + version = "5.0.24"; + sha256 = "sha256-6CVQOHN3yFTq6OyVkZMYEjIKfFbQZ6M5KAa3k7qv4Gc="; + patches = [ ./fix-build-with-boost-1.79-5_0-linux.patch ]; + } + else lib.optionalAttrs stdenv.isDarwin + { + version = "5.0.3"; # at least darwin has to stay on 5.0.3 until the SDK used by nixpkgs is bumped to 10.13 + sha256 = "1p9pq0dfd6lynvnz5p1c8dqp4filzrz86j840xwxwx82dm1zl6p0"; + patches = [ ./fix-build-with-boost-1.79-5_0.patch ]; # no darwin in name to prevent unnecessary rebuild + }; +in +buildMongoDB { + version = variants.version; + sha256 = variants.sha256; + patches = [ + ./forget-build-dependencies-4-4.patch + ./asio-no-experimental-string-view-4-4.patch + ./fix-gcc-Wno-exceptions-5.0.patch + ] ++ variants.patches; +} diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/6.0.nix b/nixpkgs/pkgs/servers/nosql/mongodb/6.0.nix new file mode 100644 index 000000000000..b17c41916928 --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/6.0.nix @@ -0,0 +1,21 @@ +{ stdenv, callPackage, lib, fetchpatch, sasl, boost, Security, CoreFoundation, cctools }: + +let + buildMongoDB = callPackage ./mongodb.nix { + inherit sasl boost Security CoreFoundation cctools stdenv; + }; +in +buildMongoDB { + version = "6.0.13"; + sha256 = "sha256-BD3XrTdv4sCa3h37o1A2s3/R0R8zHiR59a4pY0RxLGU="; + patches = [ + # Patches a bug that it couldn't build MongoDB 6.0 on gcc 13 because a include in ctype.h was missing + ./fix-gcc-13-ctype-6_0.patch + + (fetchpatch { + name = "mongodb-6.1.0-rc-more-specific-cache-alignment-types.patch"; + url = "https://github.com/mongodb/mongo/commit/5435f9585f857f6145beaf6d31daf336453ba86f.patch"; + sha256 = "sha256-gWlE2b/NyGe2243iNCXzjcERIY8/4ZWI4Gjh5SF0tYA="; + }) + ]; +} diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/asio-no-experimental-string-view-4-4.patch b/nixpkgs/pkgs/servers/nosql/mongodb/asio-no-experimental-string-view-4-4.patch new file mode 100644 index 000000000000..b27145d57ecf --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/asio-no-experimental-string-view-4-4.patch @@ -0,0 +1,23 @@ +--- a/src/third_party/asio-master/asio/include/asio/detail/config.hpp +--- b/src/third_party/asio-master/asio/include/asio/detail/config.hpp +@@ -831,20 +831,8 @@ + # endif // (__cplusplus >= 201402) + # endif // (_LIBCPP_VERSION < 7000) + # else // defined(ASIO_HAS_CLANG_LIBCXX) +-# if (__cplusplus >= 201402) +-# if __has_include(<experimental/string_view>) +-# define ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1 +-# endif // __has_include(<experimental/string_view>) +-# endif // (__cplusplus >= 201402) + # endif // // defined(ASIO_HAS_CLANG_LIBCXX) + # endif // defined(__clang__) +-# if defined(__GNUC__) +-# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) || (__GNUC__ > 4) +-# if (__cplusplus >= 201402) +-# define ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1 +-# endif // (__cplusplus >= 201402) +-# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) || (__GNUC__ > 4) +-# endif // defined(__GNUC__) + # endif // !defined(ASIO_DISABLE_STD_EXPERIMENTAL_STRING_VIEW) + #endif // !defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) + diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/fix-build-with-boost-1.79-4_4.patch b/nixpkgs/pkgs/servers/nosql/mongodb/fix-build-with-boost-1.79-4_4.patch new file mode 100644 index 000000000000..72da249f2380 --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/fix-build-with-boost-1.79-4_4.patch @@ -0,0 +1,93 @@ +From f0c7e9190e9d61515ab3f95c6665754d3b972cd1 Mon Sep 17 00:00:00 2001 +From: Et7f3 <cadeaudeelie@gmail.com> +Date: Tue, 19 Jul 2022 22:11:11 +0200 +Subject: [PATCH] build: Upgrade boost to 1.79.0 + +We can see in src/third_party/boost-1.70.0/boost/version.hpp that vendored +version of boost is BOOST_LIB_VERSION "1_70" + +We can also see the doc desbribe 2 headers to use filesystems lib: One is +src/third_party/boost/boost/filesystem/fstream.hpp that contains (175-177) + typedef basic_ifstream<char> ifstream; + typedef basic_ofstream<char> ofstream; + typedef basic_fstream<char> fstream; + +So this mean they mostly forgot to include a header and include-what-you-use +would catch this error. + +In upstream they fixed in a simmilar way +https://github.com/mongodb/mongo/commit/13389dc222fc372442be8c147e09685bb9a26a3a + +Co-Authored-By: Adrian Pistol <vifino@tty.sh> +--- + src/mongo/db/storage/storage_repair_observer.cpp | 1 + + src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp | 1 + + src/mongo/shell/shell_utils_extended.cpp | 1 + + src/mongo/util/processinfo_linux.cpp | 2 +- + src/mongo/util/stacktrace_threads.cpp | 1 + + 5 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/mongo/db/storage/storage_repair_observer.cpp b/src/mongo/db/storage/storage_repair_observer.cpp +index 22b76a6a39c..453f48229cd 100644 +--- a/src/mongo/db/storage/storage_repair_observer.cpp ++++ b/src/mongo/db/storage/storage_repair_observer.cpp +@@ -42,6 +42,7 @@ + #endif + + #include <boost/filesystem/path.hpp> ++#include <boost/filesystem/fstream.hpp> + + #include "mongo/db/dbhelpers.h" + #include "mongo/db/operation_context.h" +diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +index ee87aca4723..bde2c1b2b83 100644 +--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp ++++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +@@ -37,6 +37,7 @@ + + #include <boost/filesystem.hpp> + #include <boost/filesystem/path.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <pcrecpp.h> + + #include "mongo/base/simple_string_data_comparator.h" +diff --git a/src/mongo/shell/shell_utils_extended.cpp b/src/mongo/shell/shell_utils_extended.cpp +index 8cd7f035f1d..cd672eb513f 100644 +--- a/src/mongo/shell/shell_utils_extended.cpp ++++ b/src/mongo/shell/shell_utils_extended.cpp +@@ -37,6 +37,7 @@ + #endif + + #include <boost/filesystem.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <fstream> + + #include "mongo/bson/bson_validate.h" +diff --git a/src/mongo/util/processinfo_linux.cpp b/src/mongo/util/processinfo_linux.cpp +index 9063f140988..d74949d45fc 100644 +--- a/src/mongo/util/processinfo_linux.cpp ++++ b/src/mongo/util/processinfo_linux.cpp +@@ -33,7 +33,7 @@ + + #include "processinfo.h" + +-#include <iostream> ++#include <fstream> + #include <malloc.h> + #include <pcrecpp.h> + #include <sched.h> +diff --git a/src/mongo/util/stacktrace_threads.cpp b/src/mongo/util/stacktrace_threads.cpp +index 4667a261ab7..73a36015bd6 100644 +--- a/src/mongo/util/stacktrace_threads.cpp ++++ b/src/mongo/util/stacktrace_threads.cpp +@@ -36,6 +36,7 @@ + #include <array> + #include <atomic> + #include <boost/filesystem.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <cctype> + #include <cstdint> + #include <cstdlib> +-- +2.39.2 + diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/fix-build-with-boost-1.79-5_0-linux.patch b/nixpkgs/pkgs/servers/nosql/mongodb/fix-build-with-boost-1.79-5_0-linux.patch new file mode 100644 index 000000000000..eb205bd92894 --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/fix-build-with-boost-1.79-5_0-linux.patch @@ -0,0 +1,90 @@ +From fb846bdbd07cc3b8ada6179dccd974072c2b69da Mon Sep 17 00:00:00 2001 +From: Et7f3 <cadeaudeelie@gmail.com> +Date: Tue, 19 Jul 2022 22:01:56 +0200 +Subject: [PATCH] build: Upgrade boost to 1.79.0 + +We can see in src/third_party/boost/boost/version.hpp that vendored version of +boost is BOOST_LIB_VERSION "1_76" + +We can also see the doc desbribe 2 headers to use filesystems lib: One is +src/third_party/boost/boost/filesystem/fstream.hpp that contains (175-177) + typedef basic_ifstream<char> ifstream; + typedef basic_ofstream<char> ofstream; + typedef basic_fstream<char> fstream; + +So this mean they mostly forgot to include a header and include-what-you-use +would catch this error. + +In upstream they fixed in a simmilar way +https://github.com/mongodb/mongo/commit/13389dc222fc372442be8c147e09685bb9a26a3a +--- + src/mongo/db/storage/storage_repair_observer.cpp | 1 + + src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp | 1 + + src/mongo/shell/shell_utils_extended.cpp | 1 + + src/mongo/util/processinfo_linux.cpp | 1 + + src/mongo/util/stacktrace_threads.cpp | 1 + + 5 files changed, 5 insertions(+) + +diff --git a/src/mongo/db/storage/storage_repair_observer.cpp b/src/mongo/db/storage/storage_repair_observer.cpp +index 22b76a6a39c..453f48229cd 100644 +--- a/src/mongo/db/storage/storage_repair_observer.cpp ++++ b/src/mongo/db/storage/storage_repair_observer.cpp +@@ -42,6 +42,7 @@ + #endif + + #include <boost/filesystem/path.hpp> ++#include <boost/filesystem/fstream.hpp> + + #include "mongo/db/dbhelpers.h" + #include "mongo/db/operation_context.h" +diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +index 2f032e4..d1a90e0 100644 +--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp ++++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +@@ -37,6 +37,7 @@ + + #include <boost/filesystem.hpp> + #include <boost/filesystem/path.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <pcrecpp.h> + + #include "mongo/base/simple_string_data_comparator.h" +diff --git a/src/mongo/shell/shell_utils_extended.cpp b/src/mongo/shell/shell_utils_extended.cpp +index fbdddc1318d..e37d4c93a11 100644 +--- a/src/mongo/shell/shell_utils_extended.cpp ++++ b/src/mongo/shell/shell_utils_extended.cpp +@@ -37,6 +37,7 @@ + #endif + + #include <boost/filesystem.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <fmt/format.h> + #include <fstream> + +diff --git a/src/mongo/util/processinfo_linux.cpp b/src/mongo/util/processinfo_linux.cpp +index eae0e9b7764..d5cd40f6039 100644 +--- a/src/mongo/util/processinfo_linux.cpp ++++ b/src/mongo/util/processinfo_linux.cpp +@@ -52,6 +52,7 @@ + #endif + + #include <boost/filesystem.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <boost/none.hpp> + #include <boost/optional.hpp> + #include <fmt/format.h> +diff --git a/src/mongo/util/stacktrace_threads.cpp b/src/mongo/util/stacktrace_threads.cpp +index d2ee29d24b4..d485fa22367 100644 +--- a/src/mongo/util/stacktrace_threads.cpp ++++ b/src/mongo/util/stacktrace_threads.cpp +@@ -36,6 +36,7 @@ + #include <array> + #include <atomic> + #include <boost/filesystem.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <cstdint> + #include <cstdlib> + #include <dirent.h> +-- +2.32.1 (Apple Git-133) + diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/fix-build-with-boost-1.79-5_0.patch b/nixpkgs/pkgs/servers/nosql/mongodb/fix-build-with-boost-1.79-5_0.patch new file mode 100644 index 000000000000..d00ed5e77d67 --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/fix-build-with-boost-1.79-5_0.patch @@ -0,0 +1,90 @@ +From fb846bdbd07cc3b8ada6179dccd974072c2b69da Mon Sep 17 00:00:00 2001 +From: Et7f3 <cadeaudeelie@gmail.com> +Date: Tue, 19 Jul 2022 22:01:56 +0200 +Subject: [PATCH] build: Upgrade boost to 1.79.0 + +We can see in src/third_party/boost/boost/version.hpp that vendored version of +boost is BOOST_LIB_VERSION "1_76" + +We can also see the doc desbribe 2 headers to use filesystems lib: One is +src/third_party/boost/boost/filesystem/fstream.hpp that contains (175-177) + typedef basic_ifstream<char> ifstream; + typedef basic_ofstream<char> ofstream; + typedef basic_fstream<char> fstream; + +So this mean they mostly forgot to include a header and include-what-you-use +would catch this error. + +In upstream they fixed in a simmilar way +https://github.com/mongodb/mongo/commit/13389dc222fc372442be8c147e09685bb9a26a3a +--- + src/mongo/db/storage/storage_repair_observer.cpp | 1 + + src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp | 1 + + src/mongo/shell/shell_utils_extended.cpp | 1 + + src/mongo/util/processinfo_linux.cpp | 1 + + src/mongo/util/stacktrace_threads.cpp | 1 + + 5 files changed, 5 insertions(+) + +diff --git a/src/mongo/db/storage/storage_repair_observer.cpp b/src/mongo/db/storage/storage_repair_observer.cpp +index 22b76a6a39c..453f48229cd 100644 +--- a/src/mongo/db/storage/storage_repair_observer.cpp ++++ b/src/mongo/db/storage/storage_repair_observer.cpp +@@ -42,6 +42,7 @@ + #endif + + #include <boost/filesystem/path.hpp> ++#include <boost/filesystem/fstream.hpp> + + #include "mongo/db/dbhelpers.h" + #include "mongo/db/operation_context.h" +diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +index 07fabadd634..2924a2c74af 100644 +--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp ++++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +@@ -37,6 +37,7 @@ + + #include <boost/filesystem.hpp> + #include <boost/filesystem/path.hpp> ++#include <boost/filesystem/fstream.hpp> + + #include "mongo/base/simple_string_data_comparator.h" + #include "mongo/bson/bsonobjbuilder.h" +diff --git a/src/mongo/shell/shell_utils_extended.cpp b/src/mongo/shell/shell_utils_extended.cpp +index fbdddc1318d..e37d4c93a11 100644 +--- a/src/mongo/shell/shell_utils_extended.cpp ++++ b/src/mongo/shell/shell_utils_extended.cpp +@@ -37,6 +37,7 @@ + #endif + + #include <boost/filesystem.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <fmt/format.h> + #include <fstream> + +diff --git a/src/mongo/util/processinfo_linux.cpp b/src/mongo/util/processinfo_linux.cpp +index eae0e9b7764..d5cd40f6039 100644 +--- a/src/mongo/util/processinfo_linux.cpp ++++ b/src/mongo/util/processinfo_linux.cpp +@@ -52,6 +52,7 @@ + #endif + + #include <boost/filesystem.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <boost/none.hpp> + #include <boost/optional.hpp> + #include <fmt/format.h> +diff --git a/src/mongo/util/stacktrace_threads.cpp b/src/mongo/util/stacktrace_threads.cpp +index d2ee29d24b4..d485fa22367 100644 +--- a/src/mongo/util/stacktrace_threads.cpp ++++ b/src/mongo/util/stacktrace_threads.cpp +@@ -36,6 +36,7 @@ + #include <array> + #include <atomic> + #include <boost/filesystem.hpp> ++#include <boost/filesystem/fstream.hpp> + #include <cstdint> + #include <cstdlib> + #include <dirent.h> +-- +2.32.1 (Apple Git-133) + diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/fix-gcc-13-ctype-6_0.patch b/nixpkgs/pkgs/servers/nosql/mongodb/fix-gcc-13-ctype-6_0.patch new file mode 100644 index 000000000000..5473997e56c9 --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/fix-gcc-13-ctype-6_0.patch @@ -0,0 +1,12 @@ +diff --git a/src/mongo/util/ctype.h b/src/mongo/util/ctype.h +index a3880e2..78ee57e 100644 +--- a/src/mongo/util/ctype.h ++++ b/src/mongo/util/ctype.h +@@ -67,6 +67,7 @@ + #pragma once + + #include <array> ++#include <cstdint> + + namespace mongo::ctype { + namespace detail { diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/fix-gcc-Wno-exceptions-5.0.patch b/nixpkgs/pkgs/servers/nosql/mongodb/fix-gcc-Wno-exceptions-5.0.patch new file mode 100644 index 000000000000..b8803911968b --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/fix-gcc-Wno-exceptions-5.0.patch @@ -0,0 +1,44 @@ +From e78b2bf6eaa0c43bd76dbb841add167b443d2bb0 Mon Sep 17 00:00:00 2001 +From: Mark Benvenuto <mark.benvenuto@mongodb.com> +Date: Mon, 21 Jun 2021 11:36:56 -0400 +Subject: [PATCH] SERVER-57688 Fix debug gcc 11 and clang 12 builds on Fedora + 34 + +--- + SConstruct | 4 ---- + src/mongo/db/query/plan_summary_stats.h | 4 +++- + src/mongo/util/shim_boost_assert.cpp | 1 + + 3 files changed, 4 insertions(+), 5 deletions(-) + +diff --git a/SConstruct b/SConstruct +index 25fd4a248d0c..23cff6f9da53 100644 +--- a/SConstruct ++++ b/SConstruct +@@ -3108,10 +3108,6 @@ def doConfigure(myenv): + # harmful to capture unused variables we are suppressing for now with a plan to fix later. + AddToCCFLAGSIfSupported(myenv, "-Wno-unused-lambda-capture") + +- # This warning was added in clang-5 and incorrectly flags our implementation of +- # exceptionToStatus(). See https://bugs.llvm.org/show_bug.cgi?id=34804 +- AddToCCFLAGSIfSupported(myenv, "-Wno-exceptions") +- + # Enable sized deallocation support. + AddToCXXFLAGSIfSupported(myenv, '-fsized-deallocation') + +diff --git a/src/mongo/db/query/plan_summary_stats.h b/src/mongo/db/query/plan_summary_stats.h +index 58677ab20d25..cfaa2053d16f 100644 +--- a/src/mongo/db/query/plan_summary_stats.h ++++ b/src/mongo/db/query/plan_summary_stats.h +@@ -29,9 +29,11 @@ + + #pragma once + +-#include "mongo/util/container_size_helper.h" ++#include <optional> + #include <string> + ++#include "mongo/util/container_size_helper.h" ++ + namespace mongo { + + /** diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/forget-build-dependencies-4-4.patch b/nixpkgs/pkgs/servers/nosql/mongodb/forget-build-dependencies-4-4.patch new file mode 100644 index 000000000000..1c3e0982a8c1 --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/forget-build-dependencies-4-4.patch @@ -0,0 +1,33 @@ +--- a/site_scons/mongo/generators.py ++++ b/site_scons/mongo/generators.py +@@ -34,30 +34,12 @@ def default_buildinfo_environment_data(): + False, + ), + ( +- 'ccflags', +- '$CCFLAGS', +- True, +- False, +- ), +- ( + 'cxx', + '$CXX_VERSION', + True, + False, + ), + ( +- 'cxxflags', +- '$CXXFLAGS', +- True, +- False, +- ), +- ( +- 'linkflags', +- '$LINKFLAGS', +- True, +- False, +- ), +- ( + 'target_arch', + '$TARGET_ARCH', + True, diff --git a/nixpkgs/pkgs/servers/nosql/mongodb/mongodb.nix b/nixpkgs/pkgs/servers/nosql/mongodb/mongodb.nix new file mode 100644 index 000000000000..a51144c48d4e --- /dev/null +++ b/nixpkgs/pkgs/servers/nosql/mongodb/mongodb.nix @@ -0,0 +1,188 @@ +{ lib +, stdenv +, fetchurl +, buildPackages +, boost +, gperftools +, pcre-cpp +, snappy +, zlib +, yaml-cpp +, sasl +, net-snmp +, openldap +, openssl +, libpcap +, python3 +, curl +, Security +, CoreFoundation +, cctools +, xz +}: + +# Note: +# The command line administrative tools are part of other packages: +# see pkgs.mongodb-tools and pkgs.mongosh. + +with lib; + +{ version, sha256, patches ? [] +, license ? lib.licenses.sspl +}: + +let + scons = buildPackages.scons; + python = scons.python.withPackages (ps: with ps; [ + pyyaml + cheetah3 + psutil + setuptools + ] ++ lib.optionals (versionAtLeast version "6.0") [ + packaging + pymongo + ]); + + mozjsVersion = "60"; + mozjsReplace = "defined(HAVE___SINCOS)"; + + 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" ]; + inherit (lib) systems subtractLists; + +in stdenv.mkDerivation rec { + inherit version; + pname = "mongodb"; + + src = fetchurl { + url = "https://fastdl.mongodb.org/src/mongodb-src-r${version}.tar.gz"; + inherit sha256; + }; + + nativeBuildInputs = [ + scons + python + ] ++ lib.optional stdenv.isLinux net-snmp; + + buildInputs = [ + boost + curl + gperftools + libpcap + yaml-cpp + openssl + openldap + pcre-cpp + sasl + snappy + zlib + ] ++ lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ] + ++ lib.optional stdenv.isLinux net-snmp + ++ lib.optionals (versionAtLeast version "4.4") [ 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; + + postPatch = '' + # fix environment variable reading + substituteInPlace SConstruct \ + --replace "env = Environment(" "env = Environment(ENV = os.environ," + '' + lib.optionalString (versionAtLeast version "4.4") '' + # 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 (versionOlder version "5.0") '' + # remove -march overriding, we know better. + sed -i 's/env.Append.*-march=.*$/pass/' SConstruct + '' + lib.optionalString (stdenv.isDarwin && versionOlder version "6.0") '' + substituteInPlace src/third_party/mozjs-${mozjsVersion}/extract/js/src/jsmath.cpp --replace '${mozjsReplace}' 0 + '' + lib.optionalString (stdenv.isDarwin && versionOlder version "3.6") '' + 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 + '' + lib.optionalString stdenv.isi686 '' + + # don't fail by default on i686 + substituteInPlace src/mongo/db/storage/storage_options.h \ + --replace 'engine("wiredTiger")' 'engine("mmapv1")' + ''; + + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang + "-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 + ] ++ lib.optionals (versionAtLeast version "4.4") [ "--link-model=static" ] + ++ 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" + '' + optionalString (!stdenv.isDarwin) '' + sconsFlags+=" AR=$AR" + '' + optionalString stdenv.isAarch64 '' + 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 = + if (versionAtLeast version "6.0") then "install-devcore" + else if (versionAtLeast version "4.4") then "install-core" + else "install"; + + prefixKey = if (versionAtLeast version "4.4") then "DESTDIR=" else "--prefix="; + + enableParallelBuilding = true; + + hardeningEnable = [ "pie" ]; + + meta = { + description = "A scalable, high-performance, open source NoSQL database"; + homepage = "http://www.mongodb.org"; + inherit license; + + maintainers = with maintainers; [ bluescreen303 offline ]; + platforms = subtractLists systems.doubles.i686 systems.doubles.unix; + broken = (versionOlder version "6.0" && stdenv.system == "aarch64-darwin"); + }; +} |