about summary refs log tree commit diff
path: root/pkgs/servers/foundationdb/cmake.nix
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2019-05-02 21:44:11 -0500
committerAustin Seipp <aseipp@pobox.com>2019-05-15 09:54:10 -0500
commit3f1c6801a2d30552c06079c97d3e427854f7029a (patch)
tree7920f3d2964e120746d4e00696bc25a345ceee11 /pkgs/servers/foundationdb/cmake.nix
parenta13a0c8de447cd77e9b922ee12e700824b855ce0 (diff)
downloadnixlib-3f1c6801a2d30552c06079c97d3e427854f7029a.tar
nixlib-3f1c6801a2d30552c06079c97d3e427854f7029a.tar.gz
nixlib-3f1c6801a2d30552c06079c97d3e427854f7029a.tar.bz2
nixlib-3f1c6801a2d30552c06079c97d3e427854f7029a.tar.lz
nixlib-3f1c6801a2d30552c06079c97d3e427854f7029a.tar.xz
nixlib-3f1c6801a2d30552c06079c97d3e427854f7029a.tar.zst
nixlib-3f1c6801a2d30552c06079c97d3e427854f7029a.zip
foundationdb: init 6.1.6pre4898_26fbbbf, cmake build
This adds a new build of FoundationDB 6.1, using the new, much improved
with CMake build system with fewer patches and rough edges.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'pkgs/servers/foundationdb/cmake.nix')
-rw-r--r--pkgs/servers/foundationdb/cmake.nix129
1 files changed, 129 insertions, 0 deletions
diff --git a/pkgs/servers/foundationdb/cmake.nix b/pkgs/servers/foundationdb/cmake.nix
new file mode 100644
index 000000000000..ae693a49027f
--- /dev/null
+++ b/pkgs/servers/foundationdb/cmake.nix
@@ -0,0 +1,129 @@
+# This builder is for FoundationDB CMake build system.
+
+{ lib, fetchurl, fetchpatch, fetchFromGitHub
+, cmake, ninja, boost, python3, openjdk, mono, libressl
+
+, gccStdenv, llvmPackages
+, useClang ? true
+, ...
+}:
+
+let
+  stdenv = if useClang then llvmPackages.libcxxStdenv else gccStdenv;
+
+  tests = with builtins;
+    builtins.replaceStrings [ "\n" ] [ " " ] (lib.fileContents ./test-list.txt);
+
+  makeFdb =
+    { version
+    , branch
+    , sha256
+    , rev ? "refs/tags/${version}"
+    , officialRelease ? true
+    , patches ? []
+    }: stdenv.mkDerivation rec {
+        name = "foundationdb-${version}";
+        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"
+            "-DLIBRESSL_USE_STATIC_LIBS=FALSE"
+
+            # CMake can't find these easily for some reason?
+            "-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.
+            #
+            # TODO FIXME: bugs :(
+            (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")
+          ]
+          ++ lib.optional officialRelease [ "FDB_RELEASE=1" ];
+
+        inherit patches;
+        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