From 2e9c2a5c3c6ac2b3af8091fefcc8827b539cad20 Mon Sep 17 00:00:00 2001 From: qubitnano <146656568+qubitnano@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:08:12 -0400 Subject: [PATCH] mongodb: add avxSupport override Starting with mongodb 5, the default build produces binaries that throw a trap invalid opcode on machines without the avx cpu flag. While most modern cpus support this flag, some recent lower end Intel CPUs (N5105) do not. Allow mongodb to build without such flags. --- pkgs/servers/nosql/mongodb/5.0.nix | 6 +++++- pkgs/servers/nosql/mongodb/6.0.nix | 6 +++++- pkgs/servers/nosql/mongodb/mongodb.nix | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/nosql/mongodb/5.0.nix b/pkgs/servers/nosql/mongodb/5.0.nix index e6738239358d..22e83bb1f7f3 100644 --- a/pkgs/servers/nosql/mongodb/5.0.nix +++ b/pkgs/servers/nosql/mongodb/5.0.nix @@ -1,4 +1,7 @@ -{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }: +{ stdenv, callPackage, lib, sasl, boost +, Security, CoreFoundation, cctools +, avxSupport ? stdenv.hostPlatform.avxSupport +}: let buildMongoDB = callPackage ./mongodb.nix { @@ -18,6 +21,7 @@ let }; in buildMongoDB { + inherit avxSupport; version = variants.version; sha256 = variants.sha256; patches = [ diff --git a/pkgs/servers/nosql/mongodb/6.0.nix b/pkgs/servers/nosql/mongodb/6.0.nix index 77d825d185f3..64be3b1f5f90 100644 --- a/pkgs/servers/nosql/mongodb/6.0.nix +++ b/pkgs/servers/nosql/mongodb/6.0.nix @@ -1,4 +1,7 @@ -{ stdenv, callPackage, lib, fetchpatch, sasl, boost, Security, CoreFoundation, cctools }: +{ stdenv, callPackage, lib, fetchpatch +, sasl, boost, Security, CoreFoundation, cctools +, avxSupport ? stdenv.hostPlatform.avxSupport +}: let buildMongoDB = callPackage ./mongodb.nix { @@ -6,6 +9,7 @@ let }; in buildMongoDB { + inherit avxSupport; version = "6.0.15"; sha256 = "sha256-DX1wbrDx1/JrEHbzNaXC4Hqq7MrLqz+JZgG98beyVds="; patches = [ diff --git a/pkgs/servers/nosql/mongodb/mongodb.nix b/pkgs/servers/nosql/mongodb/mongodb.nix index f1cb57b92a6b..3dacfe4861f7 100644 --- a/pkgs/servers/nosql/mongodb/mongodb.nix +++ b/pkgs/servers/nosql/mongodb/mongodb.nix @@ -29,6 +29,7 @@ with lib; { version, sha256, patches ? [] , license ? lib.licenses.sspl +, avxSupport ? stdenv.hostPlatform.avxSupport }: let @@ -114,6 +115,9 @@ in stdenv.mkDerivation rec { # don't fail by default on i686 substituteInPlace src/mongo/db/storage/storage_options.h \ --replace 'engine("wiredTiger")' 'engine("mmapv1")' + '' + lib.optionalString (!avxSupport) '' + substituteInPlace SConstruct \ + --replace-fail "default=['+sandybridge']," 'default=[],' ''; env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang