-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Replace pre-commit with precommix or pre-commit-hooks.nix #175
Comments
I'll try to find some time to try out pre-commitx and form myself an opinion - at first sight it may look like a bit of a steeper learning curve than |
I like the idea a lot, and I'm very charmed by Nix, but I don't think this is presently a workable solution due to the aforementioned learning curve. I wish Nix were easier than it is. Just learning enough Nix to get the linters to run wouldn't be exactly sufficient, either. Inevitably, the user will want to reproduce some error that appears in the linter but not in their own Python virtualenv, and they'll need enough know-how of Nix to navigate that. |
Well, you don't really need to know nix to use precommix. Just follow some instructions to setup your dev env. The magic is actually done by direnv. You can even use pre-commit installed with pipx or apt if you prefer, and they'll be compatible. OTOH if you find it easier, we can use the same backend, but with |
Updating the list of issues in the description is becoming kinda fun... I have 14 already! 😸 |
@yajo Way too often you have a project that is mostly dormant, and when you come back a few months later some dependency is broken, and you have to find the right chain of dependency to get to a working solution again. And you have to be careful that after the version change it's using the exact same setting and doesn't start polluting all new commits by rewriting unrelated stuff in the file. These dependencies, as you have noticed, might break in one setup but not in another (I saw how frequent it is as I changed from Ubuntu to Arch repos about one year ago). With regards to the solution, I think it's a great idea, a great choice of tools and a very sane approach. @sbidoul you should definitely give it a try! |
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
Is your feature request related to a problem?
Here at OCA we use pre-commit extensively to make it more comfortable to share the same style of programming. It also bundles a lot of tools that help the coding and reviewing process.
However, pre-commit itself is divided into 3 parts:
While it's perfect for running the hooks, and pretty OK for finding them, it's not perfect for installing them. How can that be, if we pin the hook tags? Because everything that's below the hook (python version, or node version, or stdlib version, OS version, etc.) is not pinned.
The obvious outcome of this problem is that every now and then, some hook dependency starts failing, and then the CI and dev experiencie starts melting across all OCA repos. It becomes a maintenance burden with ease. Here I've collected some examples (related but not exclusive to OCA):
Describe the solution you'd like
Here at @moduon I've developed a definitive solution for this problem. It's https://gitlab.com/moduon/precommix. The base idea is that you use pre-commit for running the hooks (where it's perfect), but you use nix to install the hooks (where it's perfect too) and direnv to make them available for both pre-commit and your terminal/IDE (where it's perfect too).
Since Nix is the world's most obsessively perfect packager ever invented, once you package something there, it will keep working forever. Guaranteed. And every app bundles every dependency in a granular manner. So we will never have this problem again.
The "bad" parts of this approach:
None of these is particularly hard, but it can be annoying to bundle yet another tool in your belt for some people.
Describe alternatives you've considered
We could also bundle all current hooks in a docker image and use the docker_image language for pre-commit.
That would make you have to set up docker or podman instead of nix + direnv. This is more familiar for some people, although you lose some extra benefits of those tools.
FWIW, we also provides docker images for precommix. Although the hooks are not currently tailored for using them (that shouldn't be too hard to add).
Additional context
I've used it for months. It's a total pleasure.
The text was updated successfully, but these errors were encountered: