From 1ca5aa2e97cf2c9d4a7a20c7222dd84b8f400f40 Mon Sep 17 00:00:00 2001 From: Qyriad Date: Thu, 26 Mar 2026 12:44:48 +0100 Subject: [PATCH] packaging: don't block main crate build on its docs --- package.nix | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/package.nix b/package.nix index 08b6bbc..72c43b7 100644 --- a/package.nix +++ b/package.nix @@ -67,7 +67,9 @@ in { inherit (self) strictDeps __structuredAttrs; inherit (self) doCheck doInstallCheck; - outputs = [ "out" "doc" ]; + outputs = [ "out" ]; + # "Fake" doc output, since it's actually built as a separate derivation. + passthru.doc = self.dynixCrateDocs; src = lib.fileset.toSource { root = ./.; @@ -82,12 +84,6 @@ in { lockFile = ./Cargo.lock; }; - postInstall = '' - cargo doc --document-private-items - mkdir -p "$doc" - cp -r ./target/doc/* "$doc/" - ''; - nativeBuildInputs = rustHooks.asList ++ [ cargo ]; @@ -103,6 +99,37 @@ in { }; }; + # Run `cargo doc` as a separate derivation, so it can be run in parallel while the main + # `cargo build` of `dynixCommand`. + # This does effectively run `cargo check` twice, but that's by far the fastest part of the build, + # so it's fine imo. + dynixCrateDocs = stdenv.mkDerivation { + pname = "${self.pname}-crate-docs"; + inherit (self) version; + inherit (self) strictDeps __structuredAttrs; + inherit (self.dynixCommand) src cargoDeps nativeBuildInputs; + + phases = [ "unpackPhase" "patchPhase" "cargoDocPhase" "installPhase" ]; + + cargoDocPhase = '' + runHook preCargoDoc + cargo doc --document-private-items + runHook postCargoDoc + ''; + + installPhase = '' + runHook preInstall + mkdir -p "$out" + cp -r ./target/doc/* "$out" + runHook postInstall + ''; + + meta = { + description = "Crate Rustdoc for Dynix"; + inherit (self.meta) license; + }; + }; + dynixModules = stdenv.mkDerivation { pname = "${self.pname}-modules"; inherit (self) version;