crane/lib/cargoDoc.nix
Ivan Petkov ecf151658e
cargoDoc: do not install cargo artifacts by default (#381)
* Also install generated docs
2023-09-03 10:29:13 -07:00

28 lines
641 B
Nix

{ mkCargoDerivation
}:
{ 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
'';
})