Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkgs/build-support/rust: fix warning "build/.cargo/config is deprecated" #339281

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkgs/build-support/rust/fetch-cargo-tarball/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -96,7 +96,8 @@ 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ; is redundant.

ln -s .cargo/config.toml .cargo/config

runHook postBuild
'';
Expand Down
7 changes: 4 additions & 3 deletions pkgs/build-support/rust/hooks/cargo-setup-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ cargoSetupPostUnpackHook() {
mkdir .cargo
fi

config="$cargoDepsCopy/.cargo/config";
config="$cargoDepsCopy/.cargo/config.toml";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ; is redundant too.

if [[ ! -e $config ]]; then
config=@defaultConfig@
fi;

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
ln -s .cargo/config.toml .cargo/config

echo "Finished cargoSetupPostUnpackHook"
}
Expand Down
8 changes: 5 additions & 3 deletions pkgs/build-support/rust/import-cargo-lock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -240,7 +240,8 @@ EOF
declare -A keysSeen

for registry in ${toString (builtins.attrNames extraRegistries)}; do
cat >> $out/.cargo/config <<EOF
cat >> $out/.cargo/config.toml <<EOF
ln -s .cargo/config.toml .cargo/config
Comment on lines 242 to +244
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may fail if it is run multiple times. Can we do the ln in only one place instead?


[source."$registry"]
registry = "$registry"
Expand All @@ -256,7 +257,8 @@ 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
ln -s .cargo/config.toml .cargo/config
fi
fi
done
Expand Down