diff options
-rw-r--r-- | ci-builds.nix | 1 | ||||
-rw-r--r-- | ops/nixos/whitby/default.nix | 1 | ||||
-rw-r--r-- | third_party/abseil_cpp/default.nix | 4 | ||||
-rw-r--r-- | third_party/glog/default.nix | 5 | ||||
-rw-r--r-- | third_party/grpc/default.nix | 18 | ||||
-rw-r--r-- | third_party/nix/CMakeLists.txt | 32 | ||||
l--------- | third_party/nix/abseil_cpp | 1 | ||||
-rw-r--r-- | third_party/nix/default.nix | 30 | ||||
l--------- | third_party/nix/glog | 1 | ||||
-rw-r--r-- | third_party/nix/src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | third_party/nix/src/libstore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | third_party/nix/src/nix-daemon/nix-daemon.cc | 1 | ||||
-rw-r--r-- | third_party/nix/src/proto/CMakeLists.txt | 37 | ||||
-rw-r--r-- | third_party/nix/src/proto/worker.proto | 88 |
14 files changed, 180 insertions, 41 deletions
diff --git a/ci-builds.nix b/ci-builds.nix index a99ecd7db0ad..5ef6e58e0c7d 100644 --- a/ci-builds.nix +++ b/ci-builds.nix @@ -63,6 +63,7 @@ in lib.fix (self: { third_party = with depot.third_party; [ cgit git + grpc nix openldap ]; diff --git a/ops/nixos/whitby/default.nix b/ops/nixos/whitby/default.nix index 98e7eefab50a..73066d6b9cad 100644 --- a/ops/nixos/whitby/default.nix +++ b/ops/nixos/whitby/default.nix @@ -20,6 +20,7 @@ in systemForConfig { inherit depot; imports = [ "${depot.depotPath}/ops/nixos/depot.nix" + "${depot.depotPath}/ops/nixos/tvl-slapd/default.nix" ]; hardware = { diff --git a/third_party/abseil_cpp/default.nix b/third_party/abseil_cpp/default.nix index ec2e996d6a45..849bbbc9d51d 100644 --- a/third_party/abseil_cpp/default.nix +++ b/third_party/abseil_cpp/default.nix @@ -7,6 +7,10 @@ in llvmPackages.libcxxStdenv.mkDerivation rec { src = ./.; nativeBuildInputs = [ cmake ]; + cmakeFlags = [ + "-DCMAKE_CXX_STANDARD=17" + ]; + meta = with lib; { description = "An open-source collection of C++ code designed to augment the C++ standard library"; homepage = https://abseil.io/; diff --git a/third_party/glog/default.nix b/third_party/glog/default.nix index cebb71c290d4..575821cb49d6 100644 --- a/third_party/glog/default.nix +++ b/third_party/glog/default.nix @@ -7,7 +7,10 @@ in llvmPackages.libcxxStdenv.mkDerivation { src = ./.; nativeBuildInputs = [ cmake ]; - cmakeFlags = [ "-WITH_GFLAGS=OFF" ]; + cmakeFlags = [ + "-DCMAKE_CXX_STANDARD=17" + "-WITH_GFLAGS=OFF" + ]; meta = with lib; { homepage = "https://github.com/google/glog"; diff --git a/third_party/grpc/default.nix b/third_party/grpc/default.nix index f76467dbd651..a3745a2099ae 100644 --- a/third_party/grpc/default.nix +++ b/third_party/grpc/default.nix @@ -1,14 +1,22 @@ { pkgs, ... }: (pkgs.originals.grpc.override { + abseil-cpp = pkgs.abseil_cpp; protobuf = pkgs.protobuf; stdenv = pkgs.llvmPackages.libcxxStdenv; -}).overrideAttrs(orig: { - buildInputs = orig.buildInputs ++ [ - pkgs.abseil_cpp - ]; +}).overrideAttrs(orig: rec { + version = "1.30.0"; + + src = pkgs.fetchFromGitHub { + owner = "grpc"; + repo = "grpc"; + rev = "v${version}"; + sha256 = "01w5jdp318i7ncxbkfv75q0mf0rd3qwfr1ycdd3850nv6mprv7n0"; + fetchSubmodules = true; + }; cmakeFlags = orig.cmakeFlags ++ [ - "-DgRPC_ABSL_PROVIDER=package" + "-DCMAKE_CXX_STANDARD=17" + "-DCMAKE_CXX_STANDARD_REQUIRED=ON" ]; }) diff --git a/third_party/nix/CMakeLists.txt b/third_party/nix/CMakeLists.txt index fad650a7cade..4e6b209c3699 100644 --- a/third_party/nix/CMakeLists.txt +++ b/third_party/nix/CMakeLists.txt @@ -15,35 +15,15 @@ set(PKGCONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig) # contain useful definitions. Other dependencies are not treated # specially by CMake and are only linked into the resulting binary. find_package(BZip2) -find_package(Boost COMPONENTS context) # probably coroutine + ::headers, lets find out +find_package(Boost COMPONENTS context) find_package(CURL) +find_package(LibLZMA) +find_package(Protobuf REQUIRED) find_package(SQLite3) find_package(Threads) -find_package(LibLZMA) - -# Abseil really doesn't like being precompiled. It is included here as -# an imported CMake project (i.e. it will be built /with/ this -# project). -# -# In development mode, the 'abseil_cpp' folder is symlinked to -# ../abseil_cpp (the relative location in the depot). In derivation -# builds this symlink is automatically replaced with an appropriate -# link to the Abseil sources in the Nix store. -add_subdirectory(abseil_cpp) -install(DIRECTORY abseil_cpp/absl - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING - PATTERN "*.inc" - PATTERN "*.h" - PATTERN "copts" EXCLUDE - PATTERN "testdata" EXCLUDE - ) - -# Linking precompiled glog binaries (linked against libstdc++) leads -# to working binaries that do not output log messages. It seems that -# in order to use glog with LLVM & libc++, one needs to make glog a -# part of the local project build. -add_subdirectory(glog) +find_package(absl REQUIRED) +find_package(gRPC REQUIRED) +find_package(glog REQUIRED) # generate a configuration file (autoheader-style) to configure # certain symbols that Nix depends on. diff --git a/third_party/nix/abseil_cpp b/third_party/nix/abseil_cpp deleted file mode 120000 index cd6434fc044a..000000000000 --- a/third_party/nix/abseil_cpp +++ /dev/null @@ -1 +0,0 @@ -../abseil_cpp/ \ No newline at end of file diff --git a/third_party/nix/default.nix b/third_party/nix/default.nix index e6fa3f1f7d62..b95309ff103d 100644 --- a/third_party/nix/default.nix +++ b/third_party/nix/default.nix @@ -12,16 +12,23 @@ let largeBoehm = pkgs.boehmgc.override { enableLargeConfig = true; }; -in pkgs.llvmPackages.libcxxStdenv.mkDerivation { - pname = "tazjix"; - version = "2.3.4"; + src = ./.; - # Abseil's sources need to be symlinked into Nix' sources. - postUnpack = '' - ln -fs ${pkgs.abseil_cpp.drvAttrs.src} nix/abseil_cpp - ln -fs ${pkgs.glog.drvAttrs.src} nix/glog + # Proto generation in CMake is theoretically possible, but that is + # very theoretical - this does it in Nix instead. + protoSrcs = pkgs.runCommand "nix-proto-srcs" {} '' + export PROTO_SRCS=${src}/src/proto + mkdir -p $out/libproto + ${pkgs.protobuf}/bin/protoc -I=$PROTO_SRCS \ + --cpp_out=$out/libproto \ + --plugin=protoc-gen-grpc=${pkgs.grpc}/bin/grpc_cpp_plugin --grpc_out=$out/libproto \ + $PROTO_SRCS/*.proto ''; +in pkgs.llvmPackages.libcxxStdenv.mkDerivation { + pname = "tazjix"; + version = "2.3.4"; + inherit src; nativeBuildInputs = with pkgs; [ bison @@ -35,15 +42,20 @@ in pkgs.llvmPackages.libcxxStdenv.mkDerivation { # TODO(tazjin): Some of these might only be required for native inputs buildInputs = with pkgs; [ + abseil_cpp aws-s3-cpp brotli bzip2 + c-ares curl editline flex + glog + grpc libseccomp libsodium openssl + protobuf sqlite xz ]; @@ -53,6 +65,10 @@ in pkgs.llvmPackages.libcxxStdenv.mkDerivation { largeBoehm ]; + # Forward the location of the generated Protobuf / gRPC files so + # that they can be included by CMake. + NIX_PROTO_SRCS = protoSrcs; + # Install the various symlinks to the Nix binary which users expect # to exist. postInstall = '' diff --git a/third_party/nix/glog b/third_party/nix/glog deleted file mode 120000 index 831dc12a904c..000000000000 --- a/third_party/nix/glog +++ /dev/null @@ -1 +0,0 @@ -../glog/ \ No newline at end of file diff --git a/third_party/nix/src/CMakeLists.txt b/third_party/nix/src/CMakeLists.txt index 37ff3b54af94..3f30b1672562 100644 --- a/third_party/nix/src/CMakeLists.txt +++ b/third_party/nix/src/CMakeLists.txt @@ -5,6 +5,7 @@ # this location and this setup mimics that (with the exception of the # various Nix libraries). +add_subdirectory(proto) add_subdirectory(libutil) add_subdirectory(libstore) add_subdirectory(libmain) diff --git a/third_party/nix/src/libstore/CMakeLists.txt b/third_party/nix/src/libstore/CMakeLists.txt index 4bc7b8fd5db2..705be9574d2f 100644 --- a/third_party/nix/src/libstore/CMakeLists.txt +++ b/third_party/nix/src/libstore/CMakeLists.txt @@ -88,6 +88,7 @@ target_sources(nixstore ) target_link_libraries(nixstore + nixproto nixutil BZip2::BZip2 diff --git a/third_party/nix/src/nix-daemon/nix-daemon.cc b/third_party/nix/src/nix-daemon/nix-daemon.cc index b2161f8584db..c7967307c1ba 100644 --- a/third_party/nix/src/nix-daemon/nix-daemon.cc +++ b/third_party/nix/src/nix-daemon/nix-daemon.cc @@ -27,6 +27,7 @@ #include "libutil/serialise.hh" #include "libutil/util.hh" #include "nix/legacy.hh" +#include "libproto/worker.pb.h" using namespace nix; diff --git a/third_party/nix/src/proto/CMakeLists.txt b/third_party/nix/src/proto/CMakeLists.txt new file mode 100644 index 000000000000..726ca8742f86 --- /dev/null +++ b/third_party/nix/src/proto/CMakeLists.txt @@ -0,0 +1,37 @@ +# -*- mode: cmake; -*- +# +# The proto generation happens outside of CMake and the path to the +# generated files is passed in via the environment variable +# $NIX_PROTO_SRCS. +# +# This configuration defines a library target that compiles these +# sources and makes the headers available. + +add_library(nixproto SHARED) +set_property(TARGET nixproto PROPERTY CXX_STANDARD 17) + +set(HEADER_FILES + $ENV{NIX_PROTO_SRCS}/libproto/worker.grpc.pb.h + $ENV{NIX_PROTO_SRCS}/libproto/worker.pb.h +) + +target_sources(nixproto + PUBLIC + ${HEADER_FILES} + + PRIVATE + $ENV{NIX_PROTO_SRCS}/libproto/worker.grpc.pb.cc + $ENV{NIX_PROTO_SRCS}/libproto/worker.pb.cc +) + +target_link_libraries(nixproto + gRPC::grpc++_reflection + protobuf::libprotobuf +) + +target_include_directories(nixproto + INTERFACE $ENV{NIX_PROTO_SRCS} +) + +INSTALL(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nix/libproto) +INSTALL(TARGETS nixproto DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/third_party/nix/src/proto/worker.proto b/third_party/nix/src/proto/worker.proto new file mode 100644 index 000000000000..8db1a9e808d2 --- /dev/null +++ b/third_party/nix/src/proto/worker.proto @@ -0,0 +1,88 @@ +syntax = "proto3"; + +package nix.proto; + +// Service representing a worker used for building and interfacing +// with the Nix store. +service Worker { + // Validates whether the supplied path is a valid store path. + rpc IsValidPath (IsValidPathRequest) returns (IsValidPathResponse); + + // Checks whether any substitutes exist for the given path. + rpc HasSubstitutes (HasSubstitutesRequest) returns (HasSubstitutesResponse); + + // Query referrers for a given path. + rpc QueryReferrers (QueryReferrersRequest) returns (QueryReferrersResponse); + + // Add a NAR (I think?) to the store. The first stream request + // should be a message indicating metadata, the rest should be file + // chunks. + rpc AddToStore (stream AddToStoreRequest) returns (AddToStoreResponse); + + // Adds the supplied string to the store, as a text file. + rpc AddTextToStore (AddTextToStoreRequest) returns (AddTextToStoreResponse); +} + +enum HashType { + MD5 = 0; // TODO(tazjin): still needed? + SHA1 = 1; + SHA256 = 2; + SHA512 = 3; +} + +message IsValidPathRequest { + string path = 1; +} + +message IsValidPathResponse { + bool is_valid = 1; +} + +message HasSubstitutesRequest { + string path = 1; +} + +message HasSubstitutesResponse { + bool has_substitutes = 1; +} + +message QueryReferrersRequest { + string path = 1; +} + +message QueryReferrersResponse { + repeated string paths = 1; +} + +message AddToStoreRequest { + message Metadata { + bool fixed = 1; + bool recursive = 2; // TODO(tazjin): what is this? "obsolete" comment? + HashType hash_type = 3; + string base_name = 4; + } + + message Chunk { + bytes content = 1; + bool final = 2; + } + + oneof add_oneof { + Metadata meta = 1; + Chunk chunk = 2; + } +} + +message AddToStoreResponse { + string path = 1; +} + +message AddTextToStoreRequest { + string name = 1; + string content = 2; + repeated string references = 3; +} + +message AddTextToStoreResponse { + string path = 1; +} |