From 231ed4c11e2dfb124d56138c39971ae02fcbc51a Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 14 Mar 2023 22:16:45 +0300 Subject: feat(tvix): build (some of) our Rust documentation in Nix This will be published on docs.tvix.dev Change-Id: I348e057351d5295ad20953c9e9a32c257abab089 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8298 Tested-by: BuildkiteCI Reviewed-by: flokli --- tvix/default.nix | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'tvix') diff --git a/tvix/default.nix b/tvix/default.nix index b97d0dd00fff..19cb0fdd5aae 100644 --- a/tvix/default.nix +++ b/tvix/default.nix @@ -4,6 +4,16 @@ let # crate override for crates that need protobuf protobufDep = prev: (prev.nativeBuildInputs or [ ]) ++ [ pkgs.protobuf ]; + + # Cargo dependencies to be used with nixpkgs rustPlatform functions. + cargoDeps = pkgs.rustPlatform.importCargoLock { + lockFile = ./Cargo.lock; + outputHashes = { + "test-generator-0.3.0" = "08brp3qqa55hijc7xby3lam2cc84hvx1zzfqv6lj7smlczh8k32y"; + "tonic-mock-0.1.0" = "0lwa03hpp0mxa6aa1zv5w68k61y4hccfm0q2ykyq392fwal8vb50"; + "wu-manber-0.1.0" = "02byhfiw41mlgr1c43n2iq6jw5sbyn8l1acv5v71a07h5l18q0cy"; + }; + }; in { # Load the crate2nix crate tree. @@ -58,6 +68,27 @@ in ]; }; + # Build the Rust documentation for publishing on docs.tvix.dev. Currently only + # some crates are documented, as the crates that depend on Protobuf cause + # build failures. + rust-docs = pkgs.stdenv.mkDerivation { + inherit cargoDeps; + name = "tvix-rust-docs"; + src = depot.third_party.gitignoreSource ./.; + + nativeBuildInputs = with pkgs; [ + cargo + rust-analyzer + rustPlatform.cargoSetupHook + rustc + ]; + + buildPhase = '' + cargo doc --document-private-items -p tvix-eval -p tvix-serde -p nix-compat + mv target/doc $out + ''; + }; + export = (pkgs.runCommandLocal "export-tvix" { } '' echo "carrier for repo export extra-step" > $out '').overrideAttrs (_: { @@ -68,5 +99,5 @@ in }; }); - meta.ci.targets = [ "shell" "export" ]; + meta.ci.targets = [ "shell" "export" "rust-docs" ]; } -- cgit 1.4.1