crane/lib/cargoDoc.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
641 B
Nix
Raw Normal View History

{ mkCargoDerivation
}:
2022-10-24 02:20:22 +03:00
{ cargoDocExtraArgs ? "--no-deps"
, cargoExtraArgs ? "--locked"
, ...
}@origArgs:
let
args = (builtins.removeAttrs origArgs [
"cargoDocExtraArgs"
"cargoExtraArgs"
]);
in
mkCargoDerivation (args // {
pnameSuffix = "-doc";
buildPhaseCargoCommand = "cargoWithProfile doc ${cargoExtraArgs} ${cargoDocExtraArgs}";
doInstallCargoArtifacts = args.doInstallCargoArtifacts or false;
# NB: cargo always places docs at the root of the target directory
# even when building in release mode
installPhaseCommand = ''
mkdir -p $out/share
mv "''${CARGO_TARGET_DIR:-target}/doc" $out/share
'';
})