Files
nixpkgs/pkgs/development/compilers/rust/clippy-wrapper.nix
Marie Ramlow f3423e9fdd 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
2025-09-10 09:01:48 +02:00

35 lines
873 B
Nix

{
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
)}
''