From 3aca3d3bba54eaedefc7c472af8bca16ce1f163d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 7 Dec 2022 14:05:02 +0300 Subject: refactor(tvix): build Rust projects using crate2nix Introduces granular dependency builds using crate2nix, bootstrapped off the generated configuration from the newly introduced workspace (see cl/7533). This commit checks in the generated Cargo.nix file which can be regenerated with a parameterless invocation of `crate2nix generate` in `//tvix`. I tried generating this in IFD, but it turned out to be harder than what seemed worthwhile for now. In this setup, the various build targets for Rust projects end up being attributes of the imported `Cargo.nix` file at the `tvix.crates` attribute. These still lack configuration, however, which has been fixed in the various `default.nix` files of individual projects. Note that we (temporarily) lose the ability to build tvix-eval's benchmarks in CI. I haven't figured out what magic incantation summons them from the void again ... The `eval-okay-readDir` tests from both test suites have been disabled because they fail for unknown reasons when run in this new derivation. Somebody will have to debug it! Change-Id: I2014614ccb9c8951aedbd71df7966ca191a13695 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7538 Autosubmit: tazjin Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/store/default.nix | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'tvix/store') diff --git a/tvix/store/default.nix b/tvix/store/default.nix index 46ebcebded88..8fb80ee27bb6 100644 --- a/tvix/store/default.nix +++ b/tvix/store/default.nix @@ -1,19 +1,27 @@ -{ depot, pkgs, lib, ... }: +{ depot, pkgs, ... }: let protoRoot = depot.nix.sparseTree depot.path.origSrc [ ./protos/castore.proto ./protos/pathinfo.proto ]; -in -depot.third_party.naersk.buildPackage { - src = depot.third_party.gitignoreSource ./.; - # see https://github.com/nix-community/naersk/issues/169 - root = depot.tvix.naerskRootFor ./Cargo.toml; - nativeBuildInputs = [ pkgs.protobuf ]; + protobufDep = prev: (prev.nativeBuildInputs or [ ]) ++ [ pkgs.protobuf ]; +in +depot.tvix.crates.workspaceMembers.tvix-store.build.override { + # Ensure protobuf dependencies are available. + # TODO: figure out a way to embed this directly in the //tvix + # crate2nix config. + crateOverrides = { + prost-build = prev: { + nativeBuildInputs = protobufDep prev; + }; - PROTO_ROOT = protoRoot; + tvix-store = prev: { + PROTO_ROOT = protoRoot; + nativeBuildInputs = protobufDep prev; + }; + }; - doCheck = true; + runTests = true; } -- cgit 1.4.1