crateNameFromCargoToml: add hint for finding the source of the warning (#429)

This commit is contained in:
Ivan Petkov 2023-10-15 21:56:40 +00:00 committed by GitHub
parent 6f5679eb04
commit deec116f40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,12 @@ let
then "provided Cargo.toml contents"
else cargoToml;
hint = lib.optionalString (!lib.elem (builtins.getEnv "NIX_ABORT_ON_WARN") [ "1" "true" "yes" ]) ''
To find the source of this warning, rerun nix with:
`NIX_ABORT_ON_WARN=1 nix --option pure-eval false --show-trace ...`
'';
traceMsg = tomlName: drvName: placeholder: lib.flip lib.trivial.warn placeholder ''
crane will use a placeholder value since `${tomlName}` cannot be found in ${debugPath}
to silence this warning consider one of the following:
@ -34,6 +40,7 @@ let
- setting `package.${tomlName} = "..."` or `workspace.package.${tomlName} = "..."` in the root Cargo.toml
- explicitly looking up the values from a different Cargo.toml via
`craneLib.crateNameFromCargoToml { cargoToml = ./path/to/Cargo.toml; }`
${hint}
'';
internalName = internalCrateNameFromCargoToml toml;