Skip to content

Add pre-commit hook for nix users that does auto formatting + check with ruff and other improvements.#97

Merged
Notenlish merged 8 commits into
Notenlish:mainfrom
Immelancholy:pre-commit
Jun 9, 2026
Merged

Add pre-commit hook for nix users that does auto formatting + check with ruff and other improvements.#97
Notenlish merged 8 commits into
Notenlish:mainfrom
Immelancholy:pre-commit

Conversation

@Immelancholy

@Immelancholy Immelancholy commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Another pr lol. Further this should help with nix users to format code up to standard and also run the ruff.sh script as well! I had to modify it to use
#!/usr/bin/env bash though, which I believe is best practice for scripts anyway as not everyone has bash installed in /bin/bash, but I think env is univeral across unix systems I believe.

Only thing with this is I'm not sure what would need to be done if you wanted to use AND have a separate pre-commit. Could add a generator for the yaml file ig. Although I can't see we use pre-commit on this without nix anyway.

@Immelancholy

Immelancholy commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Taking a look at prek this could actually be used for non-nix as it accepts another file, a prek.toml, for setting it up, which would allow for both the nix pre-commit git hooks to run with .pre-commit-config.yaml and have pre-commit hooks for non-nix users. It can also be installed with pip also. See: https://prek.j178.dev/quickstart/#new-to-pre-commit-style-workflows

This would basically mean that once this is set up, we could autorun the ruff.sh script :> before committing (which happens on nix).

So if you decided you wanted a pre-commit hook set up outside of Nix stuff, we still could.

Could modify the venv activate script to install the pre-commit on run. only thin is there might need to be something to run a diff pre-commit script for windows right?

@Immelancholy

Copy link
Copy Markdown
Contributor Author

Latest commit is lwk important for the devshell, I realised that direnv doesn't reload unless you change the main flake.nix file. So had to add to the .envrc to watch src and nix dirs so they get reloaded right.

@Immelancholy

Copy link
Copy Markdown
Contributor Author

This one is a nice qol that will now always have the correct version in the nix package when building, figured out how to pull it from the pyproject.toml lol. I append the -git just cos it is building from the git main src.

@Immelancholy

Copy link
Copy Markdown
Contributor Author

I fixed the pip devshell! Now we have the good one back :>

@Immelancholy Immelancholy changed the title Add pre-commit hook for nix users, auto formats with ruff.sh and nix fmt Add pre-commit hook for nix users, auto formatting with ruff and other improvements. Jun 7, 2026
@Immelancholy Immelancholy changed the title Add pre-commit hook for nix users, auto formatting with ruff and other improvements. Add pre-commit hook for nix users that does auto formatting with ruff and other improvements. Jun 7, 2026
@Immelancholy Immelancholy changed the title Add pre-commit hook for nix users that does auto formatting with ruff and other improvements. Add pre-commit hook for nix users that does auto formatting + check with ruff and other improvements. Jun 7, 2026
@Notenlish

Notenlish commented Jun 8, 2026

Copy link
Copy Markdown
Owner

I'm going to be real I have no interest in learning nix stuff right now & don't know much about nix flakes/packages. That being said, if you have no more changes to commit I'll merge it.

@Immelancholy

Copy link
Copy Markdown
Contributor Author

Yeah, no more changes lol it's good 2 go

@Immelancholy

Copy link
Copy Markdown
Contributor Author

I'm going to be real I have no interest in learning nix stuff right now & don't know much about nix flakes/packages. That being said, if you have no more changes to commit I'll merge it.

Also on this note, I'm happy to maintain the nix package I made lol. Imma keep this package installed so that if it break I know. I'll also see if I can gently get myself back into contributing towards the python side again.

:>

@Notenlish
Notenlish merged commit 65f023d into Notenlish:main Jun 9, 2026
1 check passed
@Notenlish

Copy link
Copy Markdown
Owner

see if I can gently get myself back into contributing towards the python side again.

Wishing you luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants