Skip to content

Commit

Permalink
chore put pre-commit-checks into extra file
Browse files Browse the repository at this point in the history
  • Loading branch information
DavHau committed Oct 31, 2023
1 parent 543315a commit bc2e8dd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
21 changes: 0 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,6 @@
${pkgs.treefmt}/bin/treefmt --clear-cache "$@"
'');
};

checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
treefmt = {
enable = true;
name = "treefmt";
pass_filenames = false;
entry = l.toString (pkgs.writeScript "treefmt" ''
#!${pkgs.bash}/bin/bash
export PATH="$PATH:${l.makeBinPath [
pkgs.alejandra
pkgs.python3.pkgs.black
]}"
${pkgs.treefmt}/bin/treefmt --clear-cache --fail-on-change
'');
};
};
};
};
};
in
flake-parts.lib.mkFlake {inherit inputs;} {
Expand Down
35 changes: 35 additions & 0 deletions modules/flake-parts/pre-commit-check.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
self,
lib,
inputs,
...
}: {
perSystem = {
config,
self',
inputs',
pkgs,
...
}: {
checks = {
pre-commit-check = inputs.pre-commit-hooks.lib.${pkgs.system}.run {
src = self;
hooks = {
treefmt = {
enable = true;
name = "treefmt";
pass_filenames = false;
entry = toString (pkgs.writeScript "treefmt" ''
#!${pkgs.bash}/bin/bash
export PATH="$PATH:${lib.makeBinPath [
pkgs.alejandra
pkgs.python3.pkgs.black
]}"
${pkgs.treefmt}/bin/treefmt --clear-cache --fail-on-change
'');
};
};
};
};
};
}

0 comments on commit bc2e8dd

Please sign in to comment.