Skip to content

Commit

Permalink
Codify linting toolchain (#1251)
Browse files Browse the repository at this point in the history
* Codify linting toolchain in a toolchain file

Moves the nightly toolchain we use for linting out of a GitHub action
and into a dedicated linting `rust-toolchain.toml` file.

rustup doesn't currently support specifying a toolchain file, though
[it will soon](rust-lang/rustup#2686), so we
hack around it by keeping the toolchain files in separate directories.

* Add a Nix devShell for the linting toolchain
  • Loading branch information
Twey authored Nov 17, 2023
1 parent cd3b183 commit 7ec6f67
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ jobs:
run: >
find linera-* -name '*.rs' -a -not -wholename '*/target/*' -print0
| xargs -0 -L1 ./scripts/target/release/check_copyright_header
- name: Put lint toolchain file in place
run: |
ln -sf rust-toolchain.lint.toml rust-toolchain.toml
- uses: Twey/setup-rust-toolchain@v1
with:
toolchain: nightly-2023-10-22
target: wasm32-unknown-unknown
components: clippy rustfmt
working-directory: toolchains/lint
- name: Install cargo-machete
run: |
cargo install cargo-machete --locked
Expand Down
30 changes: 15 additions & 15 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
pkg-config
nodejs
];
rustToolchain = (pkgs.rust-bin.fromRustupToolchainFile
./rust-toolchain.toml);
rustPlatform = pkgs.makeRustPlatform {
rustc = rustToolchain;
cargo = rustToolchain;
};
rustBuildToolchain = (pkgs.rust-bin.fromRustupToolchainFile
./toolchains/build/rust-toolchain.toml);
rustLintToolchain = (pkgs.rust-bin.fromRustupToolchainFile
./toolchains/lint/rust-toolchain.toml);
in {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
Expand All @@ -45,17 +43,21 @@
];
shellHook = ''
# For rust-analyzer 'hover' tooltips to work.
export RUST_SRC_PATH=${rustToolchain.availableComponents.rust-src}
export RUST_SRC_PATH=${rustBuildToolchain.availableComponents.rust-src}
export LIBCLANG_PATH=${pkgs.libclang.lib}/lib
export PATH=$PWD/target/release:~/.cargo/bin:$PATH
'';
buildInputs = nonRustDeps;
nativeBuildInputs = with pkgs; [
rustToolchain
rustBuildToolchain
rust-analyzer
];
};

devShells.lint = pkgs.mkShell {
nativeBuildInputs = [ rustLintToolchain ];
};

# Add your auto-formatters here.
# cf. https://numtide.github.io/treefmt/
treefmt.config = {
Expand Down
5 changes: 0 additions & 5 deletions rust-toolchain.toml

This file was deleted.

1 change: 1 addition & 0 deletions rust-toolchain.toml
5 changes: 5 additions & 0 deletions toolchains/build/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "1.73.0"
components = [ "clippy", "rustfmt", "rust-src" ]
targets = [ "wasm32-unknown-unknown" ]
profile = "minimal"
4 changes: 4 additions & 0 deletions toolchains/lint/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly-2023-10-23"
components = [ "clippy", "rustfmt" ]
profile = "minimal"

0 comments on commit 7ec6f67

Please sign in to comment.