From d9d627cdf0507e44f606519384fbebd726eb0593 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 6 Dec 2022 16:47:02 +0300 Subject: refactor(tvix): share a Cargo.lock file between Rust projects This relates to the (abandoned) cl/7256. Introduces a Cargo workspace at //tvix that is primarily intended to be used as a workaround for the annoying Nix+Rust tooling while having a consistent set of dependencies. This is driven in part by a desire to adopt crate2nix and get more granular Nix builds for Tvix's Rust projects, and in part by a need to split //tvix/eval into something providing the CLI (REPL etc.), and a library providing eval, without significantly altering the structure of build targets. To accomplish this the workspace has been designed to allow projects to remain independent build targets. I want to avoid lumping all the projects together - something like //tvix/eval should always be independent of other parts of tvix. A helper function in //tvix/default.nix lets downstream naersk projects construct a sparse root for the project which combines the workspace's `Cargo.lock` with the project's own `Cargo.toml`. Note that cargo commands in the workspace itself require the build dependencies of _all_ projects to be present, which is currently a bit annoying to accomplish. This introduces some breakage: 1. It breaks usage of rust-analyser without being in a shell with the dependencies of *all* Tvix projects, as it is not capable of respecting only the subset of dependencies for a part of the workspace. 2. It is no longer possible to run tests using `cargo test`, as the test generation crate we use does not work with workspaces: https://github.com/frehberg/test-generator/issues/6 This still works in the Nix build as we construct a Cargo project that looks like it's not in a workspace there. Until somebody fixes that crate / writes a new macro / does something else with the test suite, the way to run the tests is through the Nix build. Long-term we'll probably want to get rid of cargo completely, it's just a big wart and most tooling works without it if correctly configured, but we don't have time for that now. Change-Id: I846bff7a8429a25c077fd1e9ef4e3c34a299a4a1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7533 Reviewed-by: flokli Autosubmit: tazjin Tested-by: BuildkiteCI --- tvix/store/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tvix/store/default.nix') diff --git a/tvix/store/default.nix b/tvix/store/default.nix index 4ec94cd90d9a..46ebcebded88 100644 --- a/tvix/store/default.nix +++ b/tvix/store/default.nix @@ -9,7 +9,7 @@ in depot.third_party.naersk.buildPackage { src = depot.third_party.gitignoreSource ./.; # see https://github.com/nix-community/naersk/issues/169 - root = depot.nix.sparseTree ./. [ ./Cargo.lock ./Cargo.toml ]; + root = depot.tvix.naerskRootFor ./Cargo.toml; nativeBuildInputs = [ pkgs.protobuf ]; -- cgit 1.4.1