All rust hooks fail in repositories with multiple workspaces
My repository contains multiple cargo workspaces, but all current rust hooks (rustfmt , cargo-check and clippy) assume the root to contain a Cargo.toml.
For some hooks you can set manifest-path to point to a Cargo.toml, but this does not solve my problem because I have not one, but multiple workspaces.
Would there be opposition to change manifest-path to manifest-paths (this would ofcourse be an API change....) and allow the user to specify a list of Cargo.toml files?
Would there be opposition to change manifest-path to manifest-paths (this would ofcourse be an API change....) and allow the user to specify a list of Cargo.toml files?
No, this isn't the right place to add workspace complications.
-
manifest-pathmaps directly to the CLI option, somanifest-pathswouldn't fit the pattern. - This would introduce incomplete multi-workspace support. For example, someone might want different settings per workspace.
- This won't work with
nix flake check.
The way to solve this is to use separate hooks per workspace and configure the files regex to run them against the appropriate workspace.
Until something like #593 lands, you'll have to redefine the hook definitions. You'll also have to stick with nix develop -c "pre-commit run".
Thanks for the quick response :).
Am I correct that #593 allows you to create multiple instances of a hook? Because indeed that + the manifest-path option would then probably solve my issue.
So far I've tried to make a custom hook to call rustfmt directly which seemed to work modulo the fact that there were formatting differences with calling through cargo. For clippy I tried a similar approach with clippy-driver with no luck.
Unfortunately I'm not very fluent in Nix and this seems like a huge task, otherwise Id take a stab to forward this cause. So I'll patiently wait for the support.