aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/servers/foundationdb
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-12-21 06:05:12 +0100
committerMx Kookie <kookie@spacekookie.de>2020-12-21 06:05:12 +0100
commitf107be784e6d5da5f90735765a68fdff96acfbb4 (patch)
tree145573a598009fb6adbd5ef7fbce0a850681f5f0 /infra/libkookie/nixpkgs/pkgs/servers/foundationdb
parent2e04b35e5ac3a9123cafffbc84494fa4d389cca0 (diff)
parente9158eca70ae59e73fae23be5d13d3fa0cfc78b4 (diff)
Add 'infra/libkookie/nixpkgs/' from commit 'e9158eca70ae59e73fae23be5d13d3fa0cfc78b4'
git-subtree-dir: infra/libkookie/nixpkgs git-subtree-mainline: 2e04b35e5ac3a9123cafffbc84494fa4d389cca0 git-subtree-split: e9158eca70ae59e73fae23be5d13d3fa0cfc78b4
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/servers/foundationdb')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/cmake.nix130
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/default.nix90
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/clang-libcxx.patch52
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/fix-scm-version.patch42
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/gcc-fixes.patch138
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-5.1.patch90
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-5.2.patch90
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-6.0.patch78
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/suppress-clang-warnings.patch34
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/python.nix24
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/test-list.txt80
-rw-r--r--infra/libkookie/nixpkgs/pkgs/servers/foundationdb/vsmake.nix150
12 files changed, 998 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/cmake.nix b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/cmake.nix
new file mode 100644
index 000000000000..7ad27e78d3a8
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/cmake.nix
@@ -0,0 +1,130 @@
+# This builder is for FoundationDB CMake build system.
+
+{ lib, fetchFromGitHub
+, cmake, ninja, boost, python3, openjdk, mono, libressl
+
+, gccStdenv, llvmPackages
+, useClang ? false
+, ...
+}:
+
+let
+ stdenv = if useClang then llvmPackages.libcxxStdenv else gccStdenv;
+
+ tests = with builtins;
+ builtins.replaceStrings [ "\n" ] [ " " ] (lib.fileContents ./test-list.txt);
+
+ makeFdb =
+ { version
+ , branch # unused
+ , sha256
+ , rev ? "refs/tags/${version}"
+ , officialRelease ? true
+ , patches ? []
+ }: stdenv.mkDerivation {
+ pname = "foundationdb";
+ 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;
+ enableParallelBuilding = true;
+ dontFixCmake = true;
+
+ cmakeFlags =
+ [ "-DCMAKE_BUILD_TYPE=Release"
+ (lib.optionalString officialRelease "-DFDB_RELEASE=TRUE")
+
+ # FIXME: why can't libressl be found automatically?
+ "-DLIBRESSL_USE_STATIC_LIBS=FALSE"
+ "-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")
+ ];
+
+ inherit patches;
+
+ # fix up the use of the very weird and custom 'fdb_install' command by just
+ # replacing it with cmake's ordinary version.
+ postPatch = ''
+ for x in bindings/c/CMakeLists.txt fdbserver/CMakeLists.txt fdbmonitor/CMakeLists.txt fdbbackup/CMakeLists.txt fdbcli/CMakeLists.txt; do
+ 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" ];
+
+ meta = with stdenv.lib; {
+ description = "Open source, distributed, transactional key-value store";
+ homepage = "https://www.foundationdb.org";
+ license = licenses.asl20;
+ platforms = [ "x86_64-linux" ];
+ maintainers = with maintainers; [ thoughtpolice ];
+ };
+ };
+in makeFdb
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/default.nix b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/default.nix
new file mode 100644
index 000000000000..0e608051a9ea
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/default.nix
@@ -0,0 +1,90 @@
+{ gcc6Stdenv, stdenv, gccStdenv, llvmPackages
+, lib, fetchurl, fetchpatch, fetchFromGitHub
+
+, cmake, ninja, which, findutils, m4, gawk
+, python, python3, openjdk, mono, libressl, boost
+}@args:
+
+let
+ vsmakeBuild = import ./vsmake.nix args;
+ cmakeBuild = import ./cmake.nix (args // {
+ gccStdenv = gccStdenv;
+ llvmPackages = llvmPackages;
+ });
+
+ python3-six-patch = fetchpatch {
+ name = "update-python-six.patch";
+ url = "https://github.com/apple/foundationdb/commit/4bd9efc4fc74917bc04b07a84eb065070ea7edb2.patch";
+ sha256 = "030679lmc86f1wzqqyvxnwjyfrhh54pdql20ab3iifqpp9i5mi85";
+ };
+
+ python3-print-patch = fetchpatch {
+ name = "import-for-python-print.patch";
+ url = "https://github.com/apple/foundationdb/commit/ded17c6cd667f39699cf663c0e87fe01e996c153.patch";
+ sha256 = "11y434w68cpk7shs2r22hyrpcrqi8vx02cw7v5x79qxvnmdxv2an";
+ };
+
+ glibc230-fix = fetchpatch {
+ url = "https://github.com/Ma27/foundationdb/commit/e133cb974b9a9e4e1dc2d4ac15881d31225c0197.patch";
+ sha256 = "1v9q2fyc73msigcykjnbmfig45zcrkrzcg87b0r6mxpnby8iryl1";
+ };
+
+in with builtins; {
+
+ # Older versions use the bespoke 'vsmake' build system
+ # ------------------------------------------------------
+
+ foundationdb51 = vsmakeBuild {
+ version = "5.1.7";
+ branch = "release-5.1";
+ sha256 = "1rc472ih24f9s5g3xmnlp3v62w206ny0pvvw02bzpix2sdrpbp06";
+
+ patches = [
+ ./patches/ldflags-5.1.patch
+ ./patches/fix-scm-version.patch
+ ./patches/gcc-fixes.patch
+ python3-six-patch
+ python3-print-patch
+ ];
+ };
+
+ foundationdb52 = vsmakeBuild {
+ version = "5.2.8";
+ branch = "release-5.2";
+ sha256 = "1kbmmhk2m9486r4kyjlc7bb3wd50204i0p6dxcmvl6pbp1bs0wlb";
+
+ patches = [
+ ./patches/ldflags-5.2.patch
+ ./patches/fix-scm-version.patch
+ ./patches/gcc-fixes.patch
+ python3-six-patch
+ python3-print-patch
+ ];
+ };
+
+ foundationdb60 = vsmakeBuild {
+ version = "6.0.18";
+ branch = "release-6.0";
+ sha256 = "0q1mscailad0z7zf1nypv4g7gx3damfp45nf8nzyq47nsw5gz69p";
+
+ patches = [
+ ./patches/ldflags-6.0.patch
+ ];
+ };
+
+ # 6.1 and later versions should always use CMake
+ # ------------------------------------------------------
+
+ foundationdb61 = cmakeBuild {
+ version = "6.1.12";
+ branch = "release-6.1";
+ sha256 = "1yh5hx6rim41m0dwhnb2pcwz67wlnk0zwvyw845d36b29gwy58ab";
+
+ patches = [
+ ./patches/clang-libcxx.patch
+ ./patches/suppress-clang-warnings.patch
+ glibc230-fix
+ ];
+ };
+
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/clang-libcxx.patch b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/clang-libcxx.patch
new file mode 100644
index 000000000000..ebbacdf871ea
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/clang-libcxx.patch
@@ -0,0 +1,52 @@
+commit 7ed4745a092a203f92fc37ab5894e92117db0c94
+Author: Austin Seipp <aseipp@pobox.com>
+Date: Sat May 4 15:23:35 2019 -0500
+
+ flow: fix a build failure with Clang/libcxx on Linux
+
+ 11bd7d7da introduced a hack on Linux to work around a missing symbol in
+ libstdc++'s _pic library on Ubuntu. Unfortunately, this causes the build
+ to fail when using Clang, as it doesn't believe this symbol is part of
+ its headers in c++11 mode.
+
+ Unfortunately there's no good way to distinguish libcxx from libstdc++
+ with the preprocessor, so we merely gate it by only checking for clang,
+ iff we are on Linux.
+
+ With this change, Clang 8.x can build FoundationDB on Linux using libcxx
+ as the standard C++ library.
+
+ Signed-off-by: Austin Seipp <aseipp@pobox.com>
+
+diff --git a/flow/Platform.cpp b/flow/Platform.cpp
+index 3d3f1ac0..9f21dfd4 100644
+--- a/flow/Platform.cpp
++++ b/flow/Platform.cpp
+@@ -2841,13 +2841,26 @@ void setupSlowTaskProfiler() {
+ #endif
+ }
+
+-#ifdef __linux__
++#if defined(__linux__) && !defined(__clang__)
+ // There's no good place to put this, so it's here.
+ // Ubuntu's packaging of libstdc++_pic offers different symbols than libstdc++. Go figure.
+ // Notably, it's missing a definition of std::istream::ignore(long), which causes compilation errors
+ // in the bindings. Thus, we provide weak versions of their definitions, so that if the
+ // linked-against libstdc++ is missing their definitions, we'll be able to use the provided
+ // ignore(long, int) version.
++//
++// Note that this hack is DISABLED when we use Clang. It is only needed when we statically link
++// to the _pic libraries, but only official FDB Linux binaries are built this way using GCC. If we
++// don't use the _pic libraries, then this hack is entirely unneeded -- likely the case when using
++// Clang on Linux.
++//
++// Doing this allows us to use LLVM's libc++ with Clang on Linux -- otherwise, providing
++// a weak symbol definition for an internal (non-public) class member fails (due to that member
++// being non-existant on libc++.) See upstream GitHub issue #1533 for more information.
++//
++// TODO FIXME: Obliterate this when the official build environment is upgraded beyond Ubuntu 14.04.
++// (This problem should be fixed in later LTS releases.)
++
+ #include <istream>
+ namespace std {
+ typedef basic_istream<char, std::char_traits<char>> char_basic_istream;
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/fix-scm-version.patch b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/fix-scm-version.patch
new file mode 100644
index 000000000000..0e0df7ade82b
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/fix-scm-version.patch
@@ -0,0 +1,42 @@
+diff --git a/build/scver.mk b/build/scver.mk
+index bdae8be..7539864 100644
+--- a/build/scver.mk
++++ b/build/scver.mk
+@@ -98,33 +98,10 @@ endif
+ GITPRESENT := $(wildcard $(FDBDIR)/.git)
+ HGPRESENT := $(wildcard $(FDBDIR)/.hg)
+
+-# Use Git, if not missing
+-ifneq ($(GITPRESENT),)
+- SCVER := $(shell cd "$(FDBDIR)" && git --version 2>/dev/null)
+- ifneq ($(SCVER),)
+- VERSION_ID := $(shell cd "$(FDBDIR)" && git rev-parse --verify HEAD)
+- SOURCE_CONTROL := GIT
+- SCBRANCH := $(shell cd "$(FDBDIR)" && git rev-parse --abbrev-ref HEAD)
+- else
+-$(error Missing git executable on $(PLATFORM) )
+- endif
+-# Otherwise, use Mercurial
+-else
+- # Otherwise, use Mercurial, if not missing
+- ifneq ($(HGPRESENT),)
+- SCVER := $(shell cd "$(FDBDIR)" && hg --version 2>/dev/null)
+- ifdef SCVER
+- VERSION_ID := $(shell cd "$(FDBDIR)" && hg id -n)
+- SOURCE_CONTROL := MERCURIAL
+- SCBRANCH := $(shell cd "$(FDBDIR)" && hg branch)
+- else
+-$(error Missing hg executable on $(PLATFORM))
+- endif
+- else
+- FDBFILES := (shell ls -la $(FDBDIR))
+-$(error Missing source control information for source on $(PLATFORM) in directory: $(FDBDIR) with files: $(FDBFILES))
+- endif
+-endif
++# NixOS-specific non-VCS packaging, filled out by the nix build
++SOURCE_CONTROL := GIT
++VERSION_ID := @NIXOS_FDB_VERSION_ID@
++SCBRANCH := @NIXOS_FDB_SCBRANCH@
+
+ # Set the RELEASE variable based on the KVRELEASE variable.
+ ifeq ($(KVRELEASE),1)
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/gcc-fixes.patch b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/gcc-fixes.patch
new file mode 100644
index 000000000000..a5c77d463fb5
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/gcc-fixes.patch
@@ -0,0 +1,138 @@
+diff --git a/fdbrpc/ContinuousSample.h b/fdbrpc/ContinuousSample.h
+index 54ff1b109..577c228ae 100644
+--- a/fdbrpc/ContinuousSample.h
++++ b/fdbrpc/ContinuousSample.h
+@@ -26,6 +26,7 @@
+ #include "flow/IRandom.h"
+ #include <vector>
+ #include <algorithm>
++#include <cmath>
+
+ template <class T>
+ class ContinuousSample {
+diff --git a/fdbrpc/Smoother.h b/fdbrpc/Smoother.h
+index 3ed8e6e98..fb4694750 100644
+--- a/fdbrpc/Smoother.h
++++ b/fdbrpc/Smoother.h
+@@ -23,6 +23,7 @@
+ #pragma once
+
+ #include "flow/flow.h"
++#include <cmath>
+
+ struct Smoother {
+ // Times (t) are expected to be nondecreasing
+@@ -90,4 +91,4 @@ struct TimerSmoother {
+ double time, total, estimate;
+ };
+
+-#endif
+\ No newline at end of file
++#endif
+diff --git a/fdbrpc/libcoroutine/Coro.c b/fdbrpc/libcoroutine/Coro.c
+index cbfdc8fde..9993cee44 100644
+--- a/fdbrpc/libcoroutine/Coro.c
++++ b/fdbrpc/libcoroutine/Coro.c
+@@ -66,6 +66,8 @@ VALGRIND_STACK_DEREGISTER((coro)->valgrindStackId)
+ #define STACK_DEREGISTER(coro)
+ #endif
+
++#pragma GCC diagnostic ignored "-Wreturn-local-addr"
++
+ // Define outside
+ extern intptr_t g_stackYieldLimit;
+
+diff --git a/fdbserver/Knobs.cpp b/fdbserver/Knobs.cpp
+index 819c513c6..acfbfe7db 100644
+--- a/fdbserver/Knobs.cpp
++++ b/fdbserver/Knobs.cpp
+@@ -20,6 +20,7 @@
+
+ #include "Knobs.h"
+ #include "fdbrpc/Locality.h"
++#include <cmath>
+
+ ServerKnobs const* SERVER_KNOBS = new ServerKnobs();
+
+diff --git a/flow/Knobs.cpp b/flow/Knobs.cpp
+index b485a8495..82541d439 100644
+--- a/flow/Knobs.cpp
++++ b/flow/Knobs.cpp
+@@ -20,6 +20,7 @@
+
+ #include "Knobs.h"
+ #include "flow/flow.h"
++#include <cmath>
+
+ FlowKnobs const* FLOW_KNOBS = new FlowKnobs();
+
+diff --git a/flow/Platform.cpp b/flow/Platform.cpp
+index 69dac889a..62bda9edb 100644
+--- a/flow/Platform.cpp
++++ b/flow/Platform.cpp
+@@ -40,6 +40,7 @@
+ #include <algorithm>
+
+ #include <sys/types.h>
++#include <sys/sysmacros.h>
+ #include <time.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+@@ -623,7 +624,7 @@ void getDiskStatistics(std::string const& directory, uint64_t& currentIOs, uint6
+ unsigned int minorId;
+ disk_stream >> majorId;
+ disk_stream >> minorId;
+- if(majorId == (unsigned int) major(buf.st_dev) && minorId == (unsigned int) minor(buf.st_dev)) {
++ if(majorId == (unsigned int) gnu_dev_major(buf.st_dev) && minorId == (unsigned int) gnu_dev_minor(buf.st_dev)) {
+ std::string ignore;
+ uint64_t rd_ios; /* # of reads completed */
+ // This is the total number of reads completed successfully.
+diff --git a/flow/Profiler.actor.cpp b/flow/Profiler.actor.cpp
+index 27af613e6..69f38c237 100644
+--- a/flow/Profiler.actor.cpp
++++ b/flow/Profiler.actor.cpp
+@@ -35,8 +35,6 @@
+
+ extern volatile int profilingEnabled;
+
+-static uint64_t gettid() { return syscall(__NR_gettid); }
+-
+ struct SignalClosure {
+ void (* func)(int, siginfo_t*, void*, void*);
+ void *userdata;
+diff --git a/flow/TDMetric.actor.h b/flow/TDMetric.actor.h
+index 5421b83b5..711a96093 100755
+--- a/flow/TDMetric.actor.h
++++ b/flow/TDMetric.actor.h
+@@ -36,6 +36,7 @@
+ #include "CompressedInt.h"
+ #include <algorithm>
+ #include <functional>
++#include <cmath>
+
+ struct MetricNameRef {
+ MetricNameRef() {}
+diff --git a/flow/flow.h b/flow/flow.h
+index 0c220afae..f685fbc63 100644
+--- a/flow/flow.h
++++ b/flow/flow.h
+@@ -248,19 +248,6 @@ public:
+ }
+ }
+
+- bool operator == (ErrorOr const& o) const {
+- return error == o.error && (!present() || get() == o.get());
+- }
+- bool operator != (ErrorOr const& o) const {
+- return !(*this == o);
+- }
+-
+- bool operator < (ErrorOr const& o) const {
+- if (error != o.error) return error < o.error;
+- if (!present()) return false;
+- return get() < o.get();
+- }
+-
+ bool isError() const { return error.code() != invalid_error_code; }
+ bool isError(int code) const { return error.code() == code; }
+ Error getError() const { ASSERT(isError()); return error; }
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-5.1.patch b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-5.1.patch
new file mode 100644
index 000000000000..4d523a7ecdd3
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-5.1.patch
@@ -0,0 +1,90 @@
+diff --git a/FDBLibTLS/local.mk b/FDBLibTLS/local.mk
+index 0b6eac8..b1891ca 100644
+--- a/FDBLibTLS/local.mk
++++ b/FDBLibTLS/local.mk
+@@ -1,6 +1,5 @@
+ FDBLibTLS_CFLAGS := -fPIC -I/usr/local/include -I$(BOOSTDIR)
+-FDBLibTLS_STATIC_LIBS := -ltls -lssl -lcrypto
+-FDBLibTLS_LDFLAGS := -L/usr/local/lib -static-libstdc++ -static-libgcc -lrt
++FDBLibTLS_LDFLAGS := -L/usr/local/lib -static-libstdc++ -static-libgcc -lrt -ltls -lssl -lcrypto
+ FDBLibTLS_LDFLAGS += -Wl,-soname,FDBLibTLS.so -Wl,--version-script=FDBLibTLS/FDBLibTLS.map
+
+ # The plugin isn't a typical library, so it feels more sensible to have a copy
+diff --git a/bindings/c/local.mk b/bindings/c/local.mk
+index 44f0c31..7aea5a4 100644
+--- a/bindings/c/local.mk
++++ b/bindings/c/local.mk
+@@ -29,8 +29,8 @@ fdb_c_tests_HEADERS := -Ibindings/c
+ CLEAN_TARGETS += fdb_c_tests_clean
+
+ ifeq ($(PLATFORM),linux)
+- fdb_c_LIBS += lib/libstdc++.a -lm -lpthread -lrt -ldl
+- fdb_c_LDFLAGS += -Wl,--version-script=bindings/c/fdb_c.map -static-libgcc -Wl,-z,nodelete
++ fdb_c_LIBS += lib/libstdc++.a
++ fdb_c_LDFLAGS += -Wl,--version-script=bindings/c/fdb_c.map -static-libgcc -Wl,-z,nodelete -lm -lpthread -lrt -ldl
+ fdb_c_tests_LIBS += -lpthread
+ endif
+
+diff --git a/bindings/flow/tester/local.mk b/bindings/flow/tester/local.mk
+index 2ef4fcb..6e59625 100644
+--- a/bindings/flow/tester/local.mk
++++ b/bindings/flow/tester/local.mk
+@@ -35,8 +35,7 @@ _fdb_flow_tester_clean:
+ @rm -rf bindings/flow/bin
+
+ ifeq ($(PLATFORM),linux)
+- fdb_flow_tester_LIBS += -ldl -lpthread -lrt
+- fdb_flow_tester_LDFLAGS += -static-libstdc++ -static-libgcc
++ fdb_flow_tester_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+ else ifeq ($(PLATFORM),osx)
+ fdb_flow_tester_LDFLAGS += -lc++
+ endif
+diff --git a/fdbbackup/local.mk b/fdbbackup/local.mk
+index 033fe7d..865fc92 100644
+--- a/fdbbackup/local.mk
++++ b/fdbbackup/local.mk
+@@ -25,8 +25,7 @@ fdbbackup_LDFLAGS := $(fdbrpc_LDFLAGS)
+ fdbbackup_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a
+
+ ifeq ($(PLATFORM),linux)
+- fdbbackup_LIBS += -ldl -lpthread -lrt
+- fdbbackup_LDFLAGS += -static-libstdc++ -static-libgcc
++ fdbbackup_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+
+ # GPerfTools profiler (uncomment to use)
+ # fdbbackup_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
+diff --git a/fdbcli/local.mk b/fdbcli/local.mk
+index 81a4a42..892c079 100644
+--- a/fdbcli/local.mk
++++ b/fdbcli/local.mk
+@@ -22,14 +22,13 @@
+
+ fdbcli_CFLAGS := $(fdbclient_CFLAGS)
+ fdbcli_LDFLAGS := $(fdbrpc_LDFLAGS)
+-fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a -ldl
++fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a
+ fdbcli_STATIC_LIBS :=
+
+ fdbcli_GENERATED_SOURCES += versions.h
+
+ ifeq ($(PLATFORM),linux)
+- fdbcli_LDFLAGS += -static-libstdc++ -static-libgcc
+- fdbcli_LIBS += -lpthread -lrt
++ fdbcli_LDFLAGS += -static-libstdc++ -static-libgcc -lpthread -lrt -ldl
+ else ifeq ($(PLATFORM),osx)
+ fdbcli_LDFLAGS += -lc++
+ endif
+diff --git a/fdbserver/local.mk b/fdbserver/local.mk
+index 78cad1b..36f2c0f 100644
+--- a/fdbserver/local.mk
++++ b/fdbserver/local.mk
+@@ -25,8 +25,7 @@ fdbserver_LDFLAGS := $(fdbrpc_LDFLAGS)
+ fdbserver_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a
+
+ ifeq ($(PLATFORM),linux)
+- fdbserver_LIBS += -ldl -lpthread -lrt
+- fdbserver_LDFLAGS += -static-libstdc++ -static-libgcc
++ fdbserver_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+
+ # GPerfTools profiler (uncomment to use)
+ # fdbserver_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-5.2.patch b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-5.2.patch
new file mode 100644
index 000000000000..ee5911e495f8
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-5.2.patch
@@ -0,0 +1,90 @@
+diff --git a/FDBLibTLS/local.mk b/FDBLibTLS/local.mk
+index 5e6b9cfb..73f4e5f3 100644
+--- a/FDBLibTLS/local.mk
++++ b/FDBLibTLS/local.mk
+@@ -1,6 +1,5 @@
+ FDBLibTLS_CFLAGS := -fPIC -I/usr/local/include -I$(BOOSTDIR) -Ifdbrpc
+-FDBLibTLS_STATIC_LIBS := -ltls -lssl -lcrypto
+-FDBLibTLS_LDFLAGS := -L/usr/local/lib -static-libstdc++ -static-libgcc -lrt
++FDBLibTLS_LDFLAGS := -L/usr/local/lib -static-libstdc++ -static-libgcc -lrt -ltls -lssl -lcrypto
+ FDBLibTLS_LDFLAGS += -Wl,-soname,FDBLibTLS.so -Wl,--version-script=FDBLibTLS/FDBLibTLS.map
+
+ # The plugin isn't a typical library, so it feels more sensible to have a copy
+diff --git a/bindings/c/local.mk b/bindings/c/local.mk
+index 44f0c31b..7aea5a4f 100644
+--- a/bindings/c/local.mk
++++ b/bindings/c/local.mk
+@@ -29,8 +29,8 @@ fdb_c_tests_HEADERS := -Ibindings/c
+ CLEAN_TARGETS += fdb_c_tests_clean
+
+ ifeq ($(PLATFORM),linux)
+- fdb_c_LIBS += lib/libstdc++.a -lm -lpthread -lrt -ldl
+- fdb_c_LDFLAGS += -Wl,--version-script=bindings/c/fdb_c.map -static-libgcc -Wl,-z,nodelete
++ fdb_c_LIBS += lib/libstdc++.a
++ fdb_c_LDFLAGS += -Wl,--version-script=bindings/c/fdb_c.map -static-libgcc -Wl,-z,nodelete -lm -lpthread -lrt -ldl
+ fdb_c_tests_LIBS += -lpthread
+ endif
+
+diff --git a/bindings/flow/tester/local.mk b/bindings/flow/tester/local.mk
+index 2ef4fcb7..6e59625c 100644
+--- a/bindings/flow/tester/local.mk
++++ b/bindings/flow/tester/local.mk
+@@ -35,8 +35,7 @@ _fdb_flow_tester_clean:
+ @rm -rf bindings/flow/bin
+
+ ifeq ($(PLATFORM),linux)
+- fdb_flow_tester_LIBS += -ldl -lpthread -lrt
+- fdb_flow_tester_LDFLAGS += -static-libstdc++ -static-libgcc
++ fdb_flow_tester_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+ else ifeq ($(PLATFORM),osx)
+ fdb_flow_tester_LDFLAGS += -lc++
+ endif
+diff --git a/fdbbackup/local.mk b/fdbbackup/local.mk
+index 033fe7d4..865fc923 100644
+--- a/fdbbackup/local.mk
++++ b/fdbbackup/local.mk
+@@ -25,8 +25,7 @@ fdbbackup_LDFLAGS := $(fdbrpc_LDFLAGS)
+ fdbbackup_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a
+
+ ifeq ($(PLATFORM),linux)
+- fdbbackup_LIBS += -ldl -lpthread -lrt
+- fdbbackup_LDFLAGS += -static-libstdc++ -static-libgcc
++ fdbbackup_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+
+ # GPerfTools profiler (uncomment to use)
+ # fdbbackup_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
+diff --git a/fdbcli/local.mk b/fdbcli/local.mk
+index 81a4a42e..892c079c 100644
+--- a/fdbcli/local.mk
++++ b/fdbcli/local.mk
+@@ -22,14 +22,13 @@
+
+ fdbcli_CFLAGS := $(fdbclient_CFLAGS)
+ fdbcli_LDFLAGS := $(fdbrpc_LDFLAGS)
+-fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a -ldl
++fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a
+ fdbcli_STATIC_LIBS :=
+
+ fdbcli_GENERATED_SOURCES += versions.h
+
+ ifeq ($(PLATFORM),linux)
+- fdbcli_LDFLAGS += -static-libstdc++ -static-libgcc
+- fdbcli_LIBS += -lpthread -lrt
++ fdbcli_LDFLAGS += -static-libstdc++ -static-libgcc -lpthread -lrt -ldl
+ else ifeq ($(PLATFORM),osx)
+ fdbcli_LDFLAGS += -lc++
+ endif
+diff --git a/fdbserver/local.mk b/fdbserver/local.mk
+index 78cad1bf..36f2c0f7 100644
+--- a/fdbserver/local.mk
++++ b/fdbserver/local.mk
+@@ -25,8 +25,7 @@ fdbserver_LDFLAGS := $(fdbrpc_LDFLAGS)
+ fdbserver_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a
+
+ ifeq ($(PLATFORM),linux)
+- fdbserver_LIBS += -ldl -lpthread -lrt
+- fdbserver_LDFLAGS += -static-libstdc++ -static-libgcc
++ fdbserver_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+
+ # GPerfTools profiler (uncomment to use)
+ # fdbserver_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-6.0.patch b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-6.0.patch
new file mode 100644
index 000000000000..1fa17a9615aa
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/ldflags-6.0.patch
@@ -0,0 +1,78 @@
+diff --git a/bindings/c/local.mk b/bindings/c/local.mk
+index c861a29c..ff886e93 100644
+--- a/bindings/c/local.mk
++++ b/bindings/c/local.mk
+@@ -30,8 +30,8 @@ fdb_c_tests_HEADERS := -Ibindings/c
+ CLEAN_TARGETS += fdb_c_tests_clean
+
+ ifeq ($(PLATFORM),linux)
+- fdb_c_LIBS += lib/libstdc++.a -lm -lpthread -lrt -ldl
+- fdb_c_LDFLAGS += -Wl,--version-script=bindings/c/fdb_c.map -static-libgcc -Wl,-z,nodelete
++ fdb_c_LIBS += lib/libstdc++.a
++ fdb_c_LDFLAGS += -Wl,--version-script=bindings/c/fdb_c.map -static-libgcc -Wl,-z,nodelete -lm -lpthread -lrt -ldl
+ fdb_c_tests_LIBS += -lpthread
+ endif
+
+diff --git a/bindings/flow/tester/local.mk b/bindings/flow/tester/local.mk
+index 2ef4fcb7..6e59625c 100644
+--- a/bindings/flow/tester/local.mk
++++ b/bindings/flow/tester/local.mk
+@@ -35,8 +35,7 @@ _fdb_flow_tester_clean:
+ @rm -rf bindings/flow/bin
+
+ ifeq ($(PLATFORM),linux)
+- fdb_flow_tester_LIBS += -ldl -lpthread -lrt
+- fdb_flow_tester_LDFLAGS += -static-libstdc++ -static-libgcc
++ fdb_flow_tester_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+ else ifeq ($(PLATFORM),osx)
+ fdb_flow_tester_LDFLAGS += -lc++
+ endif
+diff --git a/fdbbackup/local.mk b/fdbbackup/local.mk
+index ca5dbab6..012f0130 100644
+--- a/fdbbackup/local.mk
++++ b/fdbbackup/local.mk
+@@ -26,8 +26,7 @@ fdbbackup_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a $(FDB_TLS_LIB
+ fdbbackup_STATIC_LIBS := $(TLS_LIBS)
+
+ ifeq ($(PLATFORM),linux)
+- fdbbackup_LIBS += -ldl -lpthread -lrt
+- fdbbackup_LDFLAGS += -static-libstdc++ -static-libgcc
++ fdbbackup_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+
+ # GPerfTools profiler (uncomment to use)
+ # fdbbackup_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
+diff --git a/fdbcli/local.mk b/fdbcli/local.mk
+index fd738876..3af026b9 100644
+--- a/fdbcli/local.mk
++++ b/fdbcli/local.mk
+@@ -22,14 +22,13 @@
+
+ fdbcli_CFLAGS := $(fdbclient_CFLAGS)
+ fdbcli_LDFLAGS := $(fdbrpc_LDFLAGS)
+-fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a -ldl $(FDB_TLS_LIB)
++fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a $(FDB_TLS_LIB)
+ fdbcli_STATIC_LIBS := $(TLS_LIBS)
+
+ fdbcli_GENERATED_SOURCES += versions.h
+
+ ifeq ($(PLATFORM),linux)
+- fdbcli_LDFLAGS += -static-libstdc++ -static-libgcc
+- fdbcli_LIBS += -lpthread -lrt
++ fdbcli_LDFLAGS += -static-libstdc++ -static-libgcc -lpthread -lrt -ldl
+ else ifeq ($(PLATFORM),osx)
+ fdbcli_LDFLAGS += -lc++
+ endif
+diff --git a/fdbserver/local.mk b/fdbserver/local.mk
+index 690916d0..475abbaf 100644
+--- a/fdbserver/local.mk
++++ b/fdbserver/local.mk
+@@ -26,8 +26,7 @@ fdbserver_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a $(FDB_TLS_LIB
+ fdbserver_STATIC_LIBS := $(TLS_LIBS)
+
+ ifeq ($(PLATFORM),linux)
+- fdbserver_LIBS += -ldl -lpthread -lrt
+- fdbserver_LDFLAGS += -static-libstdc++ -static-libgcc
++ fdbserver_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+
+ # GPerfTools profiler (uncomment to use)
+ # fdbserver_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/suppress-clang-warnings.patch b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/suppress-clang-warnings.patch
new file mode 100644
index 000000000000..9d1ae992efc9
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/patches/suppress-clang-warnings.patch
@@ -0,0 +1,34 @@
+commit 8076537a52bb026941f13f5542395aac69ef0825
+Author: Austin Seipp <aseipp@pobox.com>
+Date: Sat May 4 17:34:51 2019 -0500
+
+ cmake: add workarounds for NixOS-specific deficiencies [NixOS]
+
+ The NixOS debug builder hook adds '-Wa,--compress-debug-sections' to the
+ link flags (it actually adds it to the compiler flags, but the compiler
+ is used for linking, so...). This makes the compiler angry when -Werror
+ is passed, because it's unused at link-time (-Wa applies to the
+ assembler). Suppress this warning with -Wno-unused-command-line-argument
+
+ NB: we *could* use -Wno-error=unused-command-line-argument, but that
+ still results in warnings anyway, just not fatal ones. We'd like to
+ remove them all for the sake of the build output.
+
+ Signed-off-by: Austin Seipp <aseipp@pobox.com>
+
+diff --git a/cmake/ConfigureCompiler.cmake b/cmake/ConfigureCompiler.cmake
+index 03af9c10..7d059375 100644
+--- a/cmake/ConfigureCompiler.cmake
++++ b/cmake/ConfigureCompiler.cmake
+@@ -119,6 +119,11 @@ else()
+ else()
+ add_compile_options(-Werror)
+ endif()
++ if (CLANG)
++ # aseipp: NixOS hack
++ add_compile_options(-Wno-unused-command-line-argument)
++ add_link_options(-Wno-unused-command-line-argument)
++ endif()
+ add_compile_options($<$<BOOL:${GCC}>:-Wno-pragmas>)
+ add_compile_options(-Wno-error=format
+ -Wunused-variable
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/python.nix b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/python.nix
new file mode 100644
index 000000000000..29d1f0906df7
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/python.nix
@@ -0,0 +1,24 @@
+{ buildPythonPackage, lib, foundationdb }:
+
+buildPythonPackage {
+ pname = "foundationdb";
+ version = foundationdb.version;
+
+ src = foundationdb.pythonsrc;
+ unpackCmd = "tar xf $curSrc";
+
+ patchPhase = ''
+ substituteInPlace ./fdb/impl.py \
+ --replace libfdb_c.so "${foundationdb.lib}/lib/libfdb_c.so"
+ '';
+
+ doCheck = false;
+
+ meta = with lib; {
+ description = "Python bindings for FoundationDB";
+ homepage = "https://www.foundationdb.org";
+ license = with licenses; [ asl20 ];
+ maintainers = with maintainers; [ thoughtpolice ];
+ };
+}
+
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/test-list.txt b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/test-list.txt
new file mode 100644
index 000000000000..3e9ce1428ada
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/test-list.txt
@@ -0,0 +1,80 @@
+fast/AtomicBackupCorrectness.txt
+fast/AtomicBackupToDBCorrectness.txt
+fast/AtomicOps.txt
+fast/AtomicOpsApiCorrectness.txt
+fast/BackupCorrectness.txt
+fast/BackupCorrectnessClean.txt
+fast/BackupToDBCorrectness.txt
+fast/BackupToDBCorrectnessClean.txt
+fast/CloggedSideband.txt
+fast/ConstrainedRandomSelector.txt
+fast/CycleAndLock.txt
+fast/CycleTest.txt
+fast/FuzzApiCorrectness.txt
+fast/FuzzApiCorrectnessClean.txt
+fast/IncrementTest.txt
+fast/InventoryTestAlmostReadOnly.txt
+fast/InventoryTestSomeWrites.txt
+fast/KillRegionCycle.txt
+fast/LongStackWriteDuringRead.txt
+fast/LowLatency.txt
+fast/MemoryLifetime.txt
+fast/MoveKeysCycle.txt
+fast/RandomSelector.txt
+fast/RandomUnitTests.txt
+fast/SelectorCorrectness.txt
+fast/Sideband.txt
+fast/SidebandWithStatus.txt
+fast/SwizzledRollbackSideband.txt
+fast/SystemRebootTestCycle.txt
+fast/TaskBucketCorrectness.txt
+fast/TimeKeeperCorrectness.txt
+fast/Unreadable.txt
+fast/VersionStamp.txt
+fast/Watches.txt
+fast/WriteDuringRead.txt
+fast/WriteDuringReadClean.txt
+rare/CheckRelocation.txt
+rare/ClogUnclog.txt
+rare/CloggedCycleWithKills.txt
+rare/ConflictRangeCheck.txt
+rare/ConflictRangeRYOWCheck.txt
+rare/CycleRollbackClogged.txt
+rare/CycleWithKills.txt
+rare/FuzzTest.txt
+rare/InventoryTestHeavyWrites.txt
+rare/LargeApiCorrectness.txt
+rare/LargeApiCorrectnessStatus.txt
+rare/RYWDisable.txt
+rare/RandomReadWriteTest.txt
+rare/SwizzledLargeApiCorrectness.txt
+slow/ApiCorrectness.txt
+slow/ApiCorrectnessAtomicRestore.txt
+slow/ApiCorrectnessSwitchover.txt
+slow/ClogWithRollbacks.txt
+slow/CloggedCycleTest.txt
+slow/CloggedStorefront.txt
+slow/CommitBug.txt
+slow/ConfigureTest.txt
+slow/CycleRollbackPlain.txt
+slow/DDBalanceAndRemove.txt
+slow/DDBalanceAndRemoveStatus.txt
+slow/FastTriggeredWatches.txt
+slow/LowLatencyWithFailures.txt
+slow/MoveKeysClean.txt
+slow/MoveKeysSideband.txt
+slow/RyowCorrectness.txt
+slow/Serializability.txt
+slow/SharedBackupCorrectness.txt
+slow/SharedBackupToDBCorrectness.txt
+slow/StorefrontTest.txt
+slow/SwizzledApiCorrectness.txt
+slow/SwizzledCycleTest.txt
+slow/SwizzledDdBalance.txt
+slow/SwizzledRollbackTimeLapse.txt
+slow/SwizzledRollbackTimeLapseIncrement.txt
+slow/VersionStampBackupToDB.txt
+slow/VersionStampSwitchover.txt
+slow/WriteDuringReadAtomicRestore.txt
+slow/WriteDuringReadSwitchover.txt
+slow/ddbalance.txt
diff --git a/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/vsmake.nix b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/vsmake.nix
new file mode 100644
index 000000000000..262ea39ca5b4
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/servers/foundationdb/vsmake.nix
@@ -0,0 +1,150 @@
+# This builder is for FoundationDB's original, somewhat strange visual studio +
+# make build system. In FoundationDB 6.1 and later, there's a new CMake system
+# (which will eventually become the default version.)
+{ gcc6Stdenv, lib, fetchurl, fetchFromGitHub
+
+, which, findutils, m4, gawk
+, python, openjdk, mono, libressl
+, ...
+}:
+
+let
+ # hysterical raisins dictate a version of boost this old. however,
+ # we luckily do not need to build anything, we just need the header
+ # files.
+ boost152 = gcc6Stdenv.mkDerivation {
+ name = "boost-headers-1.52.0";
+
+ src = fetchurl {
+ url = "mirror://sourceforge/boost/boost_1_52_0.tar.bz2";
+ sha256 = "14mc7gsnnahdjaxbbslzk79rc0d12h1i681cd3srdwr3fzynlar2";
+ };
+
+ dontConfigure = true;
+ buildPhase = ":";
+ installPhase = "mkdir -p $out/include && cp -R boost $out/include/";
+ };
+
+ makeFdb =
+ { version
+ , branch
+ , sha256
+
+ # the revision can be inferred from the fdb tagging policy
+ , rev ? "refs/tags/${version}"
+
+ # in theory newer versions of fdb support newer boost versions, but they
+ # don't :( maybe one day
+ , boost ? boost152
+
+ # if an release is unofficial/a prerelease, then make sure this is set
+ , officialRelease ? true
+
+ , patches ? []
+ }: gcc6Stdenv.mkDerivation {
+ pname = "foundationdb";
+ inherit version;
+
+ src = fetchFromGitHub {
+ owner = "apple";
+ repo = "foundationdb";
+ inherit rev sha256;
+ };
+
+ nativeBuildInputs = [ python openjdk gawk which m4 findutils mono ];
+ buildInputs = [ libressl boost ];
+
+ inherit patches;
+ postPatch = ''
+ # note: this does not do anything for 6.0+
+ substituteInPlace ./build/scver.mk \
+ --subst-var-by NIXOS_FDB_VERSION_ID "${rev}" \
+ --subst-var-by NIXOS_FDB_SCBRANCH "${branch}"
+
+ substituteInPlace ./Makefile \
+ --replace 'shell which ccache' 'shell true' \
+ --replace -Werror ""
+
+ substituteInPlace ./Makefile \
+ --replace libstdc++_pic libstdc++
+
+ substituteInPlace ./build/link-validate.sh \
+ --replace 'exit 1' '#exit 1'
+
+ patchShebangs .
+ '' + lib.optionalString (lib.versionAtLeast version "6.0") ''
+ substituteInPlace ./Makefile \
+ --replace 'TLS_LIBS +=' '#TLS_LIBS +=' \
+ --replace 'LDFLAGS :=' 'LDFLAGS := -ltls -lssl -lcrypto'
+ '';
+
+ separateDebugInfo = true;
+ enableParallelBuilding = true;
+
+ makeFlags = [ "all" "fdb_java" "fdb_python" ]
+ # Don't compile FDBLibTLS if we don't need it in 6.0 or later;
+ # it gets statically linked in
+ ++ lib.optional (!lib.versionAtLeast version "6.0") [ "fdb_c" ]
+ # Needed environment overrides
+ ++ [ "KVRELEASE=1"
+ "NOSTRIP=1"
+ ] ++ lib.optional officialRelease [ "RELEASE=true" ];
+
+ # on 6.0 and later, we can specify all this information manually
+ configurePhase = lib.optionalString (lib.versionAtLeast version "6.0") ''
+ export SOURCE_CONTROL=GIT
+ export SCBRANCH="${branch}"
+ export VERSION_ID="${rev}"
+ '';
+
+ installPhase = ''
+ mkdir -vp $out/{bin,libexec/plugins} $lib/{lib,share/java} $dev/include/foundationdb
+
+ '' + lib.optionalString (!lib.versionAtLeast version "6.0") ''
+ # we only copy the TLS library on < 6.0, since it's compiled-in otherwise
+ cp -v ./lib/libFDBLibTLS.so $out/libexec/plugins/FDBLibTLS.so
+ '' + ''
+
+ # C API
+ cp -v ./lib/libfdb_c.so $lib/lib
+ cp -v ./bindings/c/foundationdb/fdb_c.h $dev/include/foundationdb
+ cp -v ./bindings/c/foundationdb/fdb_c_options.g.h $dev/include/foundationdb
+ cp -v ./fdbclient/vexillographer/fdb.options $dev/include/foundationdb
+
+ # java
+ cp -v ./bindings/java/foundationdb-client.jar $lib/share/java/fdb-java.jar
+
+ # python
+ cp LICENSE ./bindings/python
+ substitute ./bindings/python/setup.py.in ./bindings/python/setup.py \
+ --replace 'VERSION' "${version}"
+ rm -f ./bindings/python/setup.py.in
+ 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/
+
+ # binaries
+ for x in fdbbackup fdbcli fdbserver fdbmonitor; do
+ cp -v "./bin/$x" $out/bin;
+ done
+
+ ln -sfv $out/bin/fdbbackup $out/bin/dr_agent
+ ln -sfv $out/bin/fdbbackup $out/bin/fdbrestore
+ ln -sfv $out/bin/fdbbackup $out/bin/fdbdr
+
+ ln -sfv $out/bin/fdbbackup $out/libexec/backup_agent
+ '';
+
+ outputs = [ "out" "lib" "dev" "pythonsrc" ];
+
+ meta = with gcc6Stdenv.lib; {
+ description = "Open source, distributed, transactional key-value store";
+ homepage = "https://www.foundationdb.org";
+ license = licenses.asl20;
+ platforms = [ "x86_64-linux" ];
+ maintainers = with maintainers; [ thoughtpolice ];
+ };
+ };
+in makeFdb