diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 120000 index 0000000..b104519 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1 @@ +/nix/store/aimf4r2pn4gapwcm87hbwx73r40cj89i-pre-commit-config.json \ No newline at end of file diff --git a/formatter.nix b/formatter.nix index 0d42f9c..3cef74a 100644 --- a/formatter.nix +++ b/formatter.nix @@ -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; + }; + }; + }; } ) diff --git a/shell.nix b/shell.nix index 072adef..261ea16 100644 --- a/shell.nix +++ b/shell.nix @@ -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]; }; })