Skip to content

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

Closed
VuiMuich wants to merge 1 commit into
NixOS:masterfrom
VuiMuich:fix/cargo-config-deprecation
Closed

pkgs/build-support/rust: fix warning "build/.cargo/config is deprecated"#339281
VuiMuich wants to merge 1 commit into
NixOS:masterfrom
VuiMuich:fix/cargo-config-deprecation

Conversation

@VuiMuich

@VuiMuich VuiMuich commented Sep 3, 2024

Copy link
Copy Markdown
Contributor

Description of changes

With a recent cargo version update the deprecation warning (see below) became more vocal.

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`

To verify this works I built the bk package, as it is very small and has very little deps.

Edit: it creates the symlink to the old /build/.cargo/confgi in case some packge enforces an old cargo version of 1.38 or older

closes #334857

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions Bot added the 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. label Sep 3, 2024
@VuiMuich VuiMuich force-pushed the fix/cargo-config-deprecation branch from 370f917 to f633cc4 Compare September 3, 2024 15:44

@emilazy emilazy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks; this has been bugging me. I’m not sure if we care about supporting Rust versions prior to 1.38, but I guess people could be using them through the various overlays.

Comment on lines 242 to +244
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

Copy link
Copy Markdown
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?

# 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
Copy Markdown
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.

fi

config="$cargoDepsCopy/.cargo/config";
config="$cargoDepsCopy/.cargo/config.toml";

Copy link
Copy Markdown
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.

@donovanglover donovanglover changed the title pkgs/build-support/rust: fix warning "build/.cargo/confgi is deprecated" pkgs/build-support/rust: fix warning "build/.cargo/config is deprecated" Sep 3, 2024
@emilazy

emilazy commented Sep 3, 2024

Copy link
Copy Markdown
Member

We need to make sure that this doesn’t invalidate the existing Cargo hashes in‐tree (i.e., that blanking out a hash still produces the same hash after this PR is applied). See #321095.

@alyssais

alyssais commented Sep 3, 2024

Copy link
Copy Markdown
Member

This looks like a duplicate of #331167. cc @mmlb. I don't know which is better.

@ofborg ofborg Bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Sep 3, 2024
@VuiMuich

VuiMuich commented Sep 3, 2024

Copy link
Copy Markdown
Contributor Author

I'm fine to close mine in favor of #331167, sind it catches a bunch of cases I missed (like pkgs/servers/clickhouse/default.nix).
The only thing my PR has over @mmlb theirs is the automatic symlinks for backwards compatibility.

@emilazy

emilazy commented Sep 3, 2024

Copy link
Copy Markdown
Member

This one would break the Cargo hashes, so I think we should close in favour of the earlier one. Thanks for taking a crack at this annoying problem anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cargo build/.cargo/config deprecation note

3 participants