Skip to content

Fix: Nix flake fails to run cargo +nightly fmt #204

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Zantier
Copy link

@Zantier Zantier commented Apr 9, 2025

Currently

If you take the following steps:

  • Install nix.
  • Create /.envrc file with contents "use flake".
  • Run direnv allow (the rust toolchain is then downloaded).

Running pre-commit run --all-files or cargo +nightly fmt (given in .pre-commit-config.yaml) fails with:

error: no such command: `+nightly`

	Cargo does not handle `+toolchain` directives.
	Did you mean to invoke `cargo` through `rustup` instead?

And I can see that the nightly toolchain is needed, because without it, cargo fmt gives:

Warning: can't set `imports_granularity = Module`, unstable features are only available in nightly channel.
Warning: can't set `group_imports = StdExternalCrate`, unstable features are only available in nightly channel.
Warning: can't set `reorder_impl_items = true`, unstable features are only available in nightly channel.
Warning: can't set `imports_granularity = Module`, unstable features are only available in nightly channel.
Warning: can't set `group_imports = StdExternalCrate`, unstable features are only available in nightly channel.
Warning: can't set `reorder_impl_items = true`, unstable features are only available in nightly channel.

This PR

This update will not affect anybody not using nix.

This PR changes the nix flake as follows:

  • Simply use rustup instead of installing a specific version of cargo.
  • Remove shell.nix:
    • Make the flake simpler.
    • The flake will refresh when you update flake.nix, but seems to incorrectly use the outdated cached shell when you update shell.nix.
  • Activate the python venv automatically when you cd to this repo. (The venv still needs to be created manually: see README.md).

PR Tests

I have tested that the following commands run successfully:

  • make build-extension-debug
  • pytest
  • cargo test
  • make test
  • pre-commit run --all-files
  • make pcc

@Zantier Zantier changed the title Fix: Outdated rust version in nix flake Fix: Nix flake missing nightly rust Apr 21, 2025
@Zantier Zantier changed the title Fix: Nix flake missing nightly rust Fix: Nix flake fails to run cargo +nightly fmt Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant