Open jeffa5 opened 3 years ago
This is a bit of a hack, but one way to do it is:
${generated}/default.nix
, copy your source tree somewhere writeable and ${generated}/cargo/config
into .cargo/config.toml
in that directory.${rustc}/bin
to your $PATH
. I also had to add ${gcc}/bin
for one of my crates which had cc
as a dev-dependency.cargo clippy --locked
in the source directory.The first and last steps are the real magic. The rest are just fixing things up. I think, in the absense of worktrees, you may also be able to do this in a Cargo.nix testPostRun
block without needing to do any source code copying or other shenanigans.
Oh, I found an even more straightforward way!
${generated}/crate
CARGO_TARGET_DIR=<somewhere writeable> CARGO_HOME=../cargo/ cargo clippy --locked
.This avoids copying and ensures you're using the same lockfile that crate2nix used to produce the cargo config. You may still need to patch up your $PATH
.
Making a derivation that runs
cargo clippy
fails due to trying to download the dependencies.Looking at the clippy page it seems it can be run as
rustc
usingclippy-driver
. Is there a way with thecrate2nix
logic to follow this through or does something need to be added tobuildRustCrate
in nixpkgs?If there is another nice way to run clippy in a derivation (looking at it for a flake check) then that would also be great.