Skip to content

Support for mono-repos? #224

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

Closed
roman opened this issue Jan 11, 2023 · 3 comments · Fixed by #225
Closed

Support for mono-repos? #224

roman opened this issue Jan 11, 2023 · 3 comments · Fixed by #225

Comments

@roman
Copy link

roman commented Jan 11, 2023

Context

As a developer that works on a project inside a monorepo
I would like to inject a pre-commit hook on a subdirectory of the git repo
So that I can take advantage of the fantastic pre-commit-hooks.nix tool

Problem

When we have a flake.nix file with a pre-commit setup that runs the shellHook on a sub-directory of the repository, the pre-commit-hooks.nix tool doesn't install the pre-commit hooks. Instead, it reports:

WARNING: pre-commit-hooks.nix: .git not found; skipping installation.

Current behavior

It seems pre-commit-hooks.nix assumes that the flake.nix file and the .git folder are in the same directory.

Expected behaviour

Ideally, we can get a pre-commit-hook installation that works only on the sub-directory of the repository that contains the flake.

Is this possible?

@domenkozar
Copy link
Member

It's currently not possible, but that could be taken into account together with #196

@roman
Copy link
Author

roman commented Jan 11, 2023

I think I can unblock with some less demanding change. I notice that if we make the .git directory check in the installation script traverse parent directories, things work as expected.

I created a PR with such a change. The PR is currently failing as it requires a package that I added to nixpkgs.

@tennox
Copy link

tennox commented Nov 24, 2024

I dug into the changes linked here - up until 3973f37, but I can't figure out how to use pre-commit hooks in a monorepo 🤔 😞

My devenv & hooks are defined in a subdirectory, but nix flake check --impure . does nothing.

Any pointers?

Edit: while realizing this I'm thinking I might just be not using git-hooks.nix right - and it's not about monorepo... will report back 🙈

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 a pull request may close this issue.

3 participants