From 3f7663c1d7cb0721ba5156364fc1d5c93674de15 Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Wed, 19 Jun 2024 14:28:58 -0400 Subject: [PATCH] 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 --- pkgs/build-support/rust/fetch-cargo-tarball/default.nix | 4 ++-- pkgs/build-support/rust/hooks/cargo-setup-hook.sh | 6 +++--- pkgs/build-support/rust/import-cargo-lock.nix | 6 +++--- pkgs/development/compilers/rust/rustc.nix | 2 +- pkgs/development/ruby-modules/gem-config/default.nix | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/build-support/rust/fetch-cargo-tarball/default.nix b/pkgs/build-support/rust/fetch-cargo-tarball/default.nix index adbfe98d81039..075e78a14e1ed 100644 --- a/pkgs/build-support/rust/fetch-cargo-tarball/default.nix +++ b/pkgs/build-support/rust/fetch-cargo-tarball/default.nix @@ -73,7 +73,7 @@ in stdenv.mkDerivation ({ ${cargoUpdateHook} - # Override the `http.cainfo` option usually specified in `.cargo/config`. + # Override the `http.cainfo` option usually specified in `.cargo/config.toml`. export CARGO_HTTP_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt if grep '^source = "git' Cargo.lock; then @@ -96,7 +96,7 @@ in 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.toml; runHook postBuild ''; diff --git a/pkgs/build-support/rust/hooks/cargo-setup-hook.sh b/pkgs/build-support/rust/hooks/cargo-setup-hook.sh index 693c0b08759ea..ccb2e565d05ca 100644 --- a/pkgs/build-support/rust/hooks/cargo-setup-hook.sh +++ b/pkgs/build-support/rust/hooks/cargo-setup-hook.sh @@ -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 diff --git a/pkgs/build-support/rust/import-cargo-lock.nix b/pkgs/build-support/rust/import-cargo-lock.nix index e3fe57ef06daa..0a365ddecba9b 100644 --- a/pkgs/build-support/rust/import-cargo-lock.nix +++ b/pkgs/build-support/rust/import-cargo-lock.nix @@ -226,7 +226,7 @@ let else "cp $lockFileContentsPath $out/Cargo.lock" } - cat > $out/.cargo/config < $out/.cargo/config.toml <> $out/.cargo/config <> $out/.cargo/config.toml <> $out/.cargo/config + cat "$crate/.cargo-config" >> $out/.cargo/config.toml fi fi done diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 1a7e22363acb1..abb887787b776 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -215,7 +215,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] diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix index 2e59b8a99cc11..3e1453d8154dd 100644 --- a/pkgs/development/ruby-modules/gem-config/default.nix +++ b/pkgs/development/ruby-modules/gem-config/default.nix @@ -326,7 +326,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 = ''