Skip to content
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

Question: how to add a custom pre-commit-hook as a devenv module? #694

Closed
roman opened this issue Jun 29, 2023 · 4 comments
Closed

Question: how to add a custom pre-commit-hook as a devenv module? #694

roman opened this issue Jun 29, 2023 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@roman
Copy link

roman commented Jun 29, 2023

Hello there 👋,

I'm trying to create a devenv module that extends the list of pre-commit-hooks available in the pre-commit.hooks option.

I tried to create a submodule override for the pre-commit submodule, but that didn't work.

I'm unfamiliar with how we can add a module system inside another, and I'm probably doing something wrong.

Could you please help me here? I appreciate any pointers you can give me.

@sagikazarmark
Copy link
Contributor

I'm looking for something similar here: #664

@domenkozar domenkozar added the documentation Improvements or additions to documentation label Jul 3, 2023
@domenkozar
Copy link
Member

Hey :) I agree we need to write docs how to write modules.

Let me know if this is blocking you!

@sagikazarmark
Copy link
Contributor

In my case, it's not blocking me per se, but it would be nice to start experimenting with custom modules and throw out some boilerplate in some of the projects I use devenv in.

If you have a quick example somewhere that would really be helpful. Thanks!

@domenkozar
Copy link
Member

An example for pre-commit:

{ pkgs, ... }: {
  # Example custom hook for a C project using Make:
  pre-commit.hooks.unit-tests = {
    enable = true;

    # The name of the hook (appears on the report table):
    name = "Unit tests";

    # The command to execute (mandatory):
    entry = "make check";

    # The pattern of files to run on (default: "" (all))
    # see also https://pre-commit.com/#hooks-files
    files = "\\.(c|h)$";

    # List of file types to run on (default: [ "file" ] (all files))
    # see also https://pre-commit.com/#filtering-files-with-types
    # You probably only need to specify one of `files` or `types`:
    types = [ "text" "c" ];

    # Exclude files that were matched by these patterns (default: [ ] (none)):
    excludes = [ "irrelevant\\.c" ];

    # The language of the hook - tells pre-commit
    # how to install the hook (default: "system")
    # see also https://pre-commit.com/#supported-languages
    language = "system";

    # Set this to false to not pass the changed files
    # to the command (default: true):
    pass_filenames = false;
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants