2019-05-03 03:44:11 +01:00
|
|
|
# This builder is for FoundationDB CMake build system.
|
|
|
|
|
2019-06-16 20:59:06 +01:00
|
|
|
{ lib, fetchFromGitHub
|
2019-05-03 03:44:11 +01:00
|
|
|
, cmake, ninja, boost, python3, openjdk, mono, libressl
|
|
|
|
|
|
|
|
, gccStdenv, llvmPackages
|
2019-10-29 20:26:20 +00:00
|
|
|
, useClang ? false
|
2019-05-03 03:44:11 +01:00
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
stdenv = if useClang then llvmPackages.libcxxStdenv else gccStdenv;
|
|
|
|
|
|
|
|
tests = with builtins;
|
|
|
|
builtins.replaceStrings [ "\n" ] [ " " ] (lib.fileContents ./test-list.txt);
|
|
|
|
|
|
|
|
makeFdb =
|
|
|
|
{ version
|
2019-06-16 20:59:06 +01:00
|
|
|
, branch # unused
|
2019-05-03 03:44:11 +01:00
|
|
|
, sha256
|
|
|
|
, rev ? "refs/tags/${version}"
|
|
|
|
, officialRelease ? true
|
|
|
|
, patches ? []
|
2019-08-13 22:52:01 +01:00
|
|
|
}: stdenv.mkDerivation {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "foundationdb";
|
2019-05-03 03:44:11 +01:00
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "apple";
|
|
|
|
repo = "foundationdb";
|
|
|
|
inherit rev sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ libressl boost ];
|
|
|
|
nativeBuildInputs = [ cmake ninja python3 openjdk mono ]
|
|
|
|
++ lib.optional useClang [ llvmPackages.lld ];
|
|
|
|
|
|
|
|
separateDebugInfo = true;
|
|
|
|
dontFixCmake = true;
|
|
|
|
|
|
|
|
cmakeFlags =
|
|
|
|
[ "-DCMAKE_BUILD_TYPE=Release"
|
2019-05-28 03:04:53 +01:00
|
|
|
(lib.optionalString officialRelease "-DFDB_RELEASE=TRUE")
|
2019-05-03 03:44:11 +01:00
|
|
|
|
2019-05-21 16:33:10 +01:00
|
|
|
# FIXME: why can't libressl be found automatically?
|
|
|
|
"-DLIBRESSL_USE_STATIC_LIBS=FALSE"
|
2019-05-03 03:44:11 +01:00
|
|
|
"-DLIBRESSL_INCLUDE_DIR=${libressl.dev}"
|
|
|
|
"-DLIBRESSL_CRYPTO_LIBRARY=${libressl.out}/lib/libcrypto.so"
|
|
|
|
"-DLIBRESSL_SSL_LIBRARY=${libressl.out}/lib/libssl.so"
|
|
|
|
"-DLIBRESSL_TLS_LIBRARY=${libressl.out}/lib/libtls.so"
|
|
|
|
|
|
|
|
# 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")
|
2019-05-21 16:33:10 +01:00
|
|
|
];
|
2019-05-03 03:44:11 +01:00
|
|
|
|
|
|
|
inherit patches;
|
2019-05-21 16:33:10 +01:00
|
|
|
|
|
|
|
# fix up the use of the very weird and custom 'fdb_install' command by just
|
|
|
|
# replacing it with cmake's ordinary version.
|
2019-05-03 03:44:11 +01:00
|
|
|
postPatch = ''
|
2021-01-03 09:43:56 +00:00
|
|
|
for x in bindings/c/CMakeLists.txt fdbserver/CMakeLists.txt fdbmonitor/CMakeLists.txt fdbbackup/CMakeLists.txt fdbcli/CMakeLists.txt; do
|
2019-05-03 03:44:11 +01:00
|
|
|
substituteInPlace $x --replace 'fdb_install' 'install'
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
postInstall = ''
|
|
|
|
mv $out/sbin/fdbserver $out/bin/fdbserver
|
|
|
|
rm -rf \
|
|
|
|
$out/lib/systemd $out/Library $out/usr $out/sbin \
|
|
|
|
$out/var $out/log $out/etc
|
|
|
|
|
|
|
|
mv $out/fdbmonitor/fdbmonitor $out/bin/fdbmonitor && rm -rf $out/fdbmonitor
|
|
|
|
|
|
|
|
rm -rf $out/lib/foundationdb/
|
|
|
|
mkdir $out/libexec && ln -sfv $out/bin/fdbbackup $out/libexec/backup_agent
|
|
|
|
|
|
|
|
mkdir $out/include/foundationdb && \
|
|
|
|
mv $out/include/*.h $out/include/*.options $out/include/foundationdb
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# include the tests
|
|
|
|
mkdir -p $out/share/test
|
|
|
|
(cd ../tests && for x in ${tests}; do
|
|
|
|
cp --parents $x $out/share/test
|
|
|
|
done)
|
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "lib" "pythonsrc" ];
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-05-03 03:44:11 +01:00
|
|
|
description = "Open source, distributed, transactional key-value store";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://www.foundationdb.org";
|
2019-05-03 03:44:11 +01:00
|
|
|
license = licenses.asl20;
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in makeFdb
|