mirror of
https://github.com/nix-community/naersk
synced 2024-11-23 04:03:04 +00:00
Add support for cargo doc
This commit is contained in:
parent
2d57092902
commit
4701ae2622
2 changed files with 22 additions and 0 deletions
21
build.nix
21
build.nix
|
@ -3,7 +3,10 @@ src:
|
|||
cargoBuild
|
||||
, #| What command to run during the test phase
|
||||
cargoTest ? "cargo test --$CARGO_BUILD_PROFILE"
|
||||
, #| What command to run during the optional doc phase
|
||||
cargoDoc ? "cargo doc --offline"
|
||||
, doCheck ? true
|
||||
, doDoc ? true
|
||||
, name
|
||||
, version
|
||||
, rustc
|
||||
|
@ -49,6 +52,9 @@ with rec
|
|||
name
|
||||
version;
|
||||
|
||||
outputs = [ "out" ] ++ lib.optional doDoc "doc";
|
||||
preInstallPhases = lib.optional doDoc [ "docPhase" ];
|
||||
|
||||
CARGO_BUILD_PROFILE = if release then "release" else "debug";
|
||||
|
||||
# Otherwise specifying CMake as a dep breaks the build
|
||||
|
@ -149,6 +155,17 @@ with rec
|
|||
runHook postCheck
|
||||
'';
|
||||
|
||||
|
||||
docPhase = lib.optionalString doDoc ''
|
||||
runHook preDoc
|
||||
|
||||
echo "Running doc command:"
|
||||
echo " ${cargoDoc}"
|
||||
${cargoDoc}
|
||||
|
||||
runHook postDoc
|
||||
'';
|
||||
|
||||
installPhase =
|
||||
''
|
||||
runHook preInstall
|
||||
|
@ -183,6 +200,10 @@ with rec
|
|||
mkdir -p $out
|
||||
cp -r target $out
|
||||
|
||||
${lib.optionalString doDoc ''
|
||||
mv $out/target/doc $doc
|
||||
''}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -162,6 +162,7 @@ with rec
|
|||
(attrs //
|
||||
{ cargoBuild = "source ${buildDepsScript}";
|
||||
doCheck = false;
|
||||
doDoc = false;
|
||||
cargolockPath = builtinz.writeTOML cargolock;
|
||||
cargotomlPath = builtinz.writeTOML
|
||||
(
|
||||
|
|
Loading…
Reference in a new issue