Add commit hook and flake check for formatting
This commit is contained in:
parent
5341235bc3
commit
591df62e58
4 changed files with 19 additions and 2 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use flake
|
1
.pre-commit-config.yaml
Symbolic link
1
.pre-commit-config.yaml
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/aimf4r2pn4gapwcm87hbwx73r40cj89i-pre-commit-config.json
|
|
@ -1,14 +1,27 @@
|
|||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
treefmt-nix,
|
||||
flake-utils,
|
||||
pre-commit-hooks,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
|
||||
treefmtWrapper = treefmtEval.config.build.wrapper;
|
||||
in {
|
||||
formatter = treefmtEval.config.build.wrapper;
|
||||
packages.formatter = treefmtWrapper;
|
||||
formatter = self.packages.${system}.formatter;
|
||||
checks.pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
treefmt = {
|
||||
enable = true;
|
||||
package = treefmtWrapper;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
self,
|
||||
flake-utils,
|
||||
nixpkgs,
|
||||
...
|
||||
|
@ -7,6 +8,7 @@ flake-utils.lib.eachDefaultSystem (system: let
|
|||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [ansible];
|
||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages ++ [pkgs.ansible];
|
||||
};
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue