2019-05-03 02:44:11 +00:00
|
|
|
# This builder is for FoundationDB CMake build system.
|
|
|
|
|
2019-06-16 19:59:06 +00:00
|
|
|
{ lib, fetchFromGitHub
|
2023-06-06 13:34:31 +00:00
|
|
|
, cmake, ninja, python3, openjdk8, mono, pkg-config
|
2024-02-12 02:22:44 +00:00
|
|
|
, msgpack-cxx, toml11
|
2019-05-03 02:44:11 +00:00
|
|
|
|
|
|
|
, gccStdenv, llvmPackages
|
2019-10-29 20:26:20 +00:00
|
|
|
, useClang ? false
|
2019-05-03 02:44:11 +00:00
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
stdenv = if useClang then llvmPackages.libcxxStdenv else gccStdenv;
|
|
|
|
|
2023-02-13 22:32:39 +00:00
|
|
|
# Only even numbered versions compile on aarch64; odd numbered versions have avx enabled.
|
|
|
|
avxEnabled = version:
|
|
|
|
let
|
|
|
|
isOdd = n: lib.trivial.mod n 2 != 0;
|
|
|
|
patch = lib.toInt (lib.versions.patch version);
|
|
|
|
in isOdd patch;
|
|
|
|
|
2019-05-03 02:44:11 +00:00
|
|
|
makeFdb =
|
|
|
|
{ version
|
2023-06-08 11:58:47 +00:00
|
|
|
, hash
|
2019-05-03 02:44:11 +00:00
|
|
|
, rev ? "refs/tags/${version}"
|
|
|
|
, officialRelease ? true
|
|
|
|
, patches ? []
|
2023-02-08 12:57:07 +00:00
|
|
|
, boost
|
|
|
|
, ssl
|
2019-08-13 21:52:01 +00:00
|
|
|
}: stdenv.mkDerivation {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "foundationdb";
|
2019-05-03 02:44:11 +00:00
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "apple";
|
|
|
|
repo = "foundationdb";
|
2023-06-08 11:58:47 +00:00
|
|
|
inherit rev hash;
|
2019-05-03 02:44:11 +00:00
|
|
|
};
|
|
|
|
|
2024-02-12 02:22:44 +00:00
|
|
|
buildInputs = [ ssl boost msgpack-cxx toml11 ];
|
2023-02-08 12:57:07 +00:00
|
|
|
|
2023-06-06 13:34:31 +00:00
|
|
|
nativeBuildInputs = [ pkg-config cmake ninja python3 openjdk8 mono ]
|
2022-10-06 16:38:53 +00:00
|
|
|
++ lib.optionals useClang [ llvmPackages.lld ];
|
2019-05-03 02:44:11 +00:00
|
|
|
|
|
|
|
separateDebugInfo = true;
|
|
|
|
dontFixCmake = true;
|
|
|
|
|
|
|
|
cmakeFlags =
|
2023-02-01 15:12:50 +00:00
|
|
|
[ (lib.optionalString officialRelease "-DFDB_RELEASE=TRUE")
|
2019-05-03 02:44:11 +00:00
|
|
|
|
2023-02-08 12:57:07 +00:00
|
|
|
# Disable CMake warnings for project developers.
|
|
|
|
"-Wno-dev"
|
|
|
|
|
|
|
|
# CMake Error at fdbserver/CMakeLists.txt:332 (find_library):
|
|
|
|
# > Could not find lz4_STATIC_LIBRARIES using the following names: liblz4.a
|
|
|
|
"-DSSD_ROCKSDB_EXPERIMENTAL=FALSE"
|
|
|
|
|
|
|
|
# FoundationDB's CMake is hardcoded to pull in jemalloc as an external
|
|
|
|
# project at build time.
|
|
|
|
"-DUSE_JEMALLOC=FALSE"
|
2019-05-03 02:44:11 +00:00
|
|
|
|
|
|
|
# LTO brings up overall build time, but results in much smaller
|
|
|
|
# binaries for all users and the cache.
|
|
|
|
(lib.optionalString (!useClang) "-DUSE_LTO=ON")
|
|
|
|
|
|
|
|
# Gold helps alleviate the link time, especially when LTO is
|
|
|
|
# enabled. But even then, it still takes a majority of the time.
|
|
|
|
# Same with LLD when Clang is available.
|
|
|
|
(lib.optionalString useClang "-DUSE_LD=LLD")
|
|
|
|
(lib.optionalString (!useClang) "-DUSE_LD=GOLD")
|
2023-06-06 13:34:31 +00:00
|
|
|
] ++ lib.optionals (lib.versionOlder version "7.2.0")
|
2023-02-08 12:57:07 +00:00
|
|
|
[ # FIXME: why can't openssl be found automatically?
|
|
|
|
"-DOPENSSL_USE_STATIC_LIBS=FALSE"
|
|
|
|
"-DOPENSSL_CRYPTO_LIBRARY=${ssl.out}/lib/libcrypto.so"
|
|
|
|
"-DOPENSSL_SSL_LIBRARY=${ssl.out}/lib/libssl.so"
|
2019-05-21 15:33:10 +00:00
|
|
|
];
|
2019-05-03 02:44:11 +00:00
|
|
|
|
2023-04-26 13:35:10 +00:00
|
|
|
hardeningDisable = [ "fortify" ];
|
|
|
|
|
2023-02-19 19:23:32 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString [
|
2022-12-23 16:57:29 +00:00
|
|
|
# Needed with GCC 12
|
|
|
|
"-Wno-error=missing-template-keyword"
|
2023-02-13 22:32:39 +00:00
|
|
|
# Needed to compile on aarch64
|
|
|
|
(lib.optionalString stdenv.hostPlatform.isAarch64 "-march=armv8-a+crc")
|
2022-12-23 16:57:29 +00:00
|
|
|
];
|
|
|
|
|
2019-05-03 02:44:11 +00:00
|
|
|
inherit patches;
|
2019-05-21 15:33:10 +00:00
|
|
|
|
2019-05-03 02:44:11 +00:00
|
|
|
# the install phase for cmake is pretty wonky right now since it's not designed to
|
|
|
|
# coherently install packages as most linux distros expect -- it's designed to build
|
|
|
|
# packaged artifacts that are shipped in RPMs, etc. we need to add some extra code to
|
|
|
|
# cmake upstream to fix this, and if we do, i think most of this can go away.
|
2023-06-06 13:34:31 +00:00
|
|
|
postInstall = ''
|
2023-02-08 12:57:07 +00:00
|
|
|
mv $out/sbin/fdbmonitor $out/bin/fdbmonitor
|
|
|
|
mkdir $out/libexec && mv $out/usr/lib/foundationdb/backup_agent/backup_agent $out/libexec/backup_agent
|
|
|
|
mv $out/sbin/fdbserver $out/bin/fdbserver
|
|
|
|
|
|
|
|
rm -rf $out/etc $out/lib/foundationdb $out/lib/systemd $out/log $out/sbin $out/usr $out/var
|
2019-05-03 02:44:11 +00:00
|
|
|
|
|
|
|
# move results into multi outputs
|
|
|
|
mkdir -p $dev $lib
|
|
|
|
mv $out/include $dev/include
|
|
|
|
mv $out/lib $lib/lib
|
|
|
|
|
|
|
|
# python bindings
|
|
|
|
# NB: use the original setup.py.in, so we can substitute VERSION correctly
|
|
|
|
cp ../LICENSE ./bindings/python
|
|
|
|
substitute ../bindings/python/setup.py.in ./bindings/python/setup.py \
|
|
|
|
--replace 'VERSION' "${version}"
|
|
|
|
rm -f ./bindings/python/setup.py.* ./bindings/python/CMakeLists.txt
|
|
|
|
rm -f ./bindings/python/fdb/*.pth # remove useless files
|
|
|
|
rm -f ./bindings/python/*.rst ./bindings/python/*.mk
|
|
|
|
|
|
|
|
cp -R ./bindings/python/ tmp-pythonsrc/
|
|
|
|
tar -zcf $pythonsrc --transform s/tmp-pythonsrc/python-foundationdb/ ./tmp-pythonsrc/
|
|
|
|
|
|
|
|
# java bindings
|
|
|
|
mkdir -p $lib/share/java
|
|
|
|
mv lib/fdb-java-*.jar $lib/share/java/fdb-java.jar
|
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "lib" "pythonsrc" ];
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-05-03 02:44:11 +00:00
|
|
|
description = "Open source, distributed, transactional key-value store";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://www.foundationdb.org";
|
2019-05-03 02:44:11 +00:00
|
|
|
license = licenses.asl20;
|
2023-02-13 22:32:39 +00:00
|
|
|
platforms = [ "x86_64-linux" ]
|
2023-06-06 13:34:31 +00:00
|
|
|
++ lib.optionals (!(avxEnabled version)) [ "aarch64-linux" ];
|
2022-02-08 04:01:47 +00:00
|
|
|
maintainers = with maintainers; [ thoughtpolice lostnet ];
|
2019-05-03 02:44:11 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in makeFdb
|