diff --git a/CHANGELOG.md b/CHANGELOG.md index fb59bdc7..184f18f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * `downloadCargoPackageFromGit` will now set `fetchLFS = true` when fetching git repos with defined output hashes +### Fixed +* `cargoDoc` correctly honors `docInstallRoot` when specified +* `cargoDoc` falls back to installing from `./target/doc` even if + `$CARGO_BUILD_TARGET` is set but `./target/$CARGO_BUILD_TARGET/doc` does not + exist + ### Removed * The deprecated top-level (flake) attribute `lib` no longer exists. Please use `mkLib` with an instance of `pkgs` instead. @@ -68,7 +74,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [0.17.2] - 2024-05-26 ### Fixed -* `removeReferencesToVendoredSources` has been optimzed to search for source +* `removeReferencesToVendoredSources` has been optimized to search for source references only once. For derivations which install many files, this phase can run up to 99% faster than before. * `cleanCargoToml` now cleans underscored versions of the same attributes (e.g. diff --git a/docs/API.md b/docs/API.md index 72483dee..f7e2501e 100644 --- a/docs/API.md +++ b/docs/API.md @@ -495,6 +495,8 @@ Except where noted below, all derivation attributes are delegated to `$CARGO_TARGET_DIR` (or default to `./target` if not set) and `$CARGO_BUILD_TARGET` (if set). - Default value: `"${CARGO_TARGET_DIR:-target}/${CARGO_BUILD_TARGET:-}/doc"` + if such a directory exists, otherwise falls back to + `"${CARGO_TARGET_DIR:-target}/doc"` #### Remove attributes The following attributes will be removed before being lowered to @@ -503,7 +505,6 @@ environment variables during the build, you can bring them back via `.overrideAttrs`. * `cargoDocExtraArgs` * `cargoExtraArgs` -* `docInstallRoot` ### `craneLib.cargoFmt` diff --git a/lib/cargoDoc.nix b/lib/cargoDoc.nix index 7422525b..82c6499d 100644 --- a/lib/cargoDoc.nix +++ b/lib/cargoDoc.nix @@ -9,7 +9,6 @@ let args = (builtins.removeAttrs origArgs [ "cargoDocExtraArgs" "cargoExtraArgs" - "docInstallRoot" ]); in mkCargoDerivation (args // { @@ -22,10 +21,17 @@ mkCargoDerivation (args // { docInstallRoot = args.docInstallRoot or ""; # NB: cargo always places docs at the root of the target directory - # even when building in release mode, except when cross-compiling targets + # even when building in release mode, except when cross-compiling targets. + # However, even if CARGO_BUILD_TARGET is set but does not result in cross-compilation + # cargo will still put the docs in the root of the target directory, so we need to take + # that into account installPhaseCommand = '' if [ -z "''${docInstallRoot:-}" ]; then docInstallRoot="''${CARGO_TARGET_DIR:-target}/''${CARGO_BUILD_TARGET:-}/doc" + + if ! [ -d "''${docInstallRoot}" ]; then + docInstallRoot="''${CARGO_TARGET_DIR:-target}/doc" + fi fi mkdir -p $out/share