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

rust: Write config.toml not config #321095

Merged
merged 1 commit into from
Jun 21, 2024
Merged
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
4 changes: 2 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,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
'';
Expand Down
6 changes: 3 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,17 +22,17 @@ cargoSetupPostUnpackHook() {
mkdir .cargo
fi

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

Choose a reason for hiding this comment

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

Suggested change
config="$cargoDepsCopy/.cargo/config.toml";
mv "$cargoDepsCopy/.cargo/config" "$cargoDepsCopy/.cargo/config.toml"
config="$cargoDepsCopy/.cargo/config.toml";

I actually mean something like this, i.e. not moving it in the FOD output, but moving it after the FOD is unpacked and copied and made writable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll give this a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this wasn't the problem, the patch that caused FOD changes was the fetch-cargo-tarball one!

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

Expand Down
6 changes: 3 additions & 3 deletions pkgs/build-support/rust/import-cargo-lock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,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 @@ -237,7 +237,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"
Expand All @@ -253,7 +253,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
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/rust/rustc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/ruby-modules/gem-config/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down