about summary refs log tree commit diff
path: root/third_party/nix/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/default.nix')
-rw-r--r--third_party/nix/default.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/third_party/nix/default.nix b/third_party/nix/default.nix
index f9989602143b..ad1ff5beebfb 100644
--- a/third_party/nix/default.nix
+++ b/third_party/nix/default.nix
@@ -52,6 +52,7 @@ in pkgs.llvmPackages.libcxxStdenv.mkDerivation {
     flex
     glog
     grpc
+    gtest
     libseccomp
     libsodium
     openssl
@@ -60,11 +61,37 @@ in pkgs.llvmPackages.libcxxStdenv.mkDerivation {
     xz
   ];
 
+  doCheck = false;
+  doInstallCheck = true;
+
   propagatedBuildInputs = with pkgs; [
     boost
     largeBoehm
   ];
 
+  configurePhase = ''
+    mkdir build
+    cd build
+    cmake .. \
+      -DCMAKE_INSTALL_PREFIX=$out \
+      -DCMAKE_BUILD_TYPE=Release \
+      -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF \
+      -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF \
+      -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
+  '';
+
+  installCheckPhase = ''
+    export NIX_DATA_DIR=$out/share
+    make test
+  '';
+
+  preBuild = ''
+    if [ -n "$NIX_BUILD_CORES" ]; then
+      makeFlags+="-j$NIX_BUILD_CORES "
+      makeFlags+="-l$NIX_BUILD_CORES "
+    fi
+  '';
+
   # Forward the location of the generated Protobuf / gRPC files so
   # that they can be included by CMake.
   NIX_PROTO_SRCS = protoSrcs;