mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 02:40:31 +08:00
clippy: fix cross linting
Clippy uses `clippy-driver` for linting, which needs to be pointed to the correct sysroot, just like our rustc. Fixes: https://github.com/NixOS/nixpkgs/issues/278508
This commit is contained in:
committed by
Alyssa Ross
parent
ab0f3607a6
commit
f3423e9fdd
34
pkgs/development/compilers/rust/clippy-wrapper.nix
Normal file
34
pkgs/development/compilers/rust/clippy-wrapper.nix
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
lib,
|
||||
runCommand,
|
||||
clippy-unwrapped,
|
||||
rustc-unwrapped,
|
||||
makeWrapper,
|
||||
}:
|
||||
|
||||
runCommand "${clippy-unwrapped.pname}-wrapper-${clippy-unwrapped.version}"
|
||||
{
|
||||
preferLocalBuild = true;
|
||||
strictDeps = true;
|
||||
inherit (clippy-unwrapped) outputs;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
meta = clippy-unwrapped.meta // {
|
||||
description = "${clippy-unwrapped.meta.description} (wrapper script)";
|
||||
priority = 10;
|
||||
};
|
||||
}
|
||||
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${clippy-unwrapped}/bin/cargo-clippy $out/bin/cargo-clippy \
|
||||
--set-default SYSROOT ${rustc-unwrapped}
|
||||
|
||||
makeWrapper ${clippy-unwrapped}/bin/clippy-driver $out/bin/clippy-driver \
|
||||
--set-default SYSROOT ${rustc-unwrapped}
|
||||
|
||||
${lib.concatMapStrings (output: "ln -s ${clippy-unwrapped.${output}} \$${output}\n") (
|
||||
lib.remove "out" clippy-unwrapped.outputs
|
||||
)}
|
||||
''
|
||||
@@ -127,12 +127,8 @@ in
|
||||
self.callPackage ./cargo_cross.nix { };
|
||||
cargo-auditable = self.callPackage ./cargo-auditable.nix { };
|
||||
cargo-auditable-cargo-wrapper = self.callPackage ./cargo-auditable-cargo-wrapper.nix { };
|
||||
clippy = self.callPackage ./clippy.nix {
|
||||
# We want to use self, not buildRustPackages, so that
|
||||
# buildPackages.clippy uses the cross compiler and supports
|
||||
# linting for the target platform.
|
||||
rustPlatform = makeRustPlatform self;
|
||||
};
|
||||
clippy-unwrapped = self.callPackage ./clippy.nix { };
|
||||
clippy = if !fastCross then self.clippy-unwrapped else self.callPackage ./clippy-wrapper.nix { };
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user