rust: Write to .cargo/config.toml instead of .cargo/config

Seeing the following new warnings pop up on stderr when cargo was bumped
to 1.78:

```
warning: `/build/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
```

which happens to break commitmsgfmt builds in nix (#320294).

closes #320294
This commit is contained in:
Manuel Mendez 2024-06-19 14:28:58 -04:00
parent d1d2419804
commit 17b3df2861
6 changed files with 12 additions and 12 deletions

View File

@ -136,7 +136,7 @@ stdenv.mkDerivation (
# Packages with git dependencies generate non-default cargo configs, so
# always install it rather than trying to write a standard default template.
install -D $CARGO_CONFIG $name/.cargo/config;
install -D $CARGO_CONFIG $name/.cargo/config
runHook postBuild
'';

View File

@ -22,7 +22,7 @@ cargoSetupPostUnpackHook() {
mkdir .cargo
fi
config="$cargoDepsCopy/.cargo/config";
config="$cargoDepsCopy/.cargo/config.toml"
if [[ ! -e $config ]]; then
config=@defaultConfig@
fi;
@ -30,9 +30,9 @@ cargoSetupPostUnpackHook() {
tmp_config=$(mktemp)
substitute $config $tmp_config \
--subst-var-by vendor "$cargoDepsCopy"
cat ${tmp_config} >> .cargo/config
cat ${tmp_config} >> .cargo/config.toml
cat >> .cargo/config <<'EOF'
cat >> .cargo/config.toml <<'EOF'
@cargoConfig@
EOF

View File

@ -229,7 +229,7 @@ let
else "cp $lockFileContentsPath $out/Cargo.lock"
}
cat > $out/.cargo/config <<EOF
cat > $out/.cargo/config.toml <<EOF
[source.crates-io]
replace-with = "vendored-sources"
@ -240,7 +240,7 @@ EOF
declare -A keysSeen
for registry in ${toString (builtins.attrNames extraRegistries)}; do
cat >> $out/.cargo/config <<EOF
cat >> $out/.cargo/config.toml <<EOF
[source."$registry"]
registry = "$registry"
@ -256,7 +256,7 @@ EOF
key=$(sed 's/\[source\."\(.*\)"\]/\1/; t; d' < "$crate/.cargo-config")
if [[ -z ''${keysSeen[$key]} ]]; then
keysSeen[$key]=1
cat "$crate/.cargo-config" >> $out/.cargo/config
cat "$crate/.cargo-config" >> $out/.cargo/config.toml
fi
fi
done

View File

@ -233,7 +233,7 @@ in stdenv.mkDerivation (finalAttrs: {
export JEMALLOC_SYS_WITH_LG_VADDR=48
'' + lib.optionalString (!(finalAttrs.src.passthru.isReleaseTarball or false)) ''
mkdir .cargo
cat > .cargo/config <<\EOF
cat > .cargo/config.toml <<\EOF
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]

View File

@ -335,7 +335,7 @@ in
rustc.unwrapped
];
preBuild = ''
cat ../.cargo/config > ext/fast_mmaped_file_rs/.cargo/config.toml
cat ../.cargo/config.toml > ext/fast_mmaped_file_rs/.cargo/config.toml
sed -i "s|cargo-vendor-dir|$PWD/../cargo-vendor-dir|" ext/fast_mmaped_file_rs/.cargo/config.toml
'';
postInstall = ''

View File

@ -133,9 +133,9 @@ in mkDerivation rec {
pushd rust
cargoDeps="$rustDeps" cargoSetupPostUnpackHook
rustDepsCopy="$cargoDepsCopy"
cat .cargo/config >> .cargo/config.toml.in
cat .cargo/config >> skim/.cargo/config.toml.in
rm .cargo/config
cat .cargo/config.toml >> .cargo/config.toml.in
cat .cargo/config.toml >> skim/.cargo/config.toml.in
rm .cargo/config.toml
popd
popd