build(flake): add pre-commit-hooks
This enforces formatting rules.
This commit is contained in:
parent
1db1b81b17
commit
df70df8062
|
@ -31,6 +31,9 @@ plugin.txt
|
|||
.idea
|
||||
.direnv
|
||||
|
||||
# Pre Commit hooks
|
||||
.pre-commit-config.yaml
|
||||
|
||||
# LS
|
||||
## lua
|
||||
.luarc.json
|
||||
|
|
54
flake.lock
54
flake.lock
|
@ -56,6 +56,58 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"git-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": [
|
||||
"flake-compat"
|
||||
],
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"gitignore": [
|
||||
"gitignore"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs-stable": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1714478972,
|
||||
"narHash": "sha256-q//cgb52vv81uOuwz1LaXElp3XAe1TqrABXODAEF6Sk=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "2849da033884f54822af194400f8dff435ada242",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709087332,
|
||||
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1714656196,
|
||||
|
@ -77,6 +129,8 @@
|
|||
"crane": "crane",
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"git-hooks": "git-hooks",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"systems": "systems",
|
||||
|
|
25
flake.nix
25
flake.nix
|
@ -35,6 +35,16 @@
|
|||
nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
git-hooks = {
|
||||
url = "github:cachix/git-hooks.nix";
|
||||
inputs = {
|
||||
flake-compat.follows = "flake-compat";
|
||||
flake-utils.follows = "flake-utils";
|
||||
gitignore.follows = "gitignore";
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
nixpkgs-stable.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs = {
|
||||
|
@ -44,6 +54,12 @@
|
|||
};
|
||||
|
||||
# inputs for following
|
||||
gitignore = {
|
||||
url = "github:hercules-ci/gitignore.nix";
|
||||
inputs = {
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
systems = {
|
||||
url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
|
||||
};
|
||||
|
@ -63,6 +79,7 @@
|
|||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
git-hooks,
|
||||
treefmt-nix,
|
||||
crane,
|
||||
rust-overlay,
|
||||
|
@ -149,11 +166,19 @@
|
|||
checks = {
|
||||
inherit craneBuild;
|
||||
formatting = treefmtEval.config.build.check self;
|
||||
pre-commit = git-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks.treefmt = {
|
||||
enable = true;
|
||||
package = treefmtEval.config.build.wrapper;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
formatter = treefmtEval.config.build.wrapper;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
inherit (self.checks.${system}.pre-commit) shellHook;
|
||||
packages = with pkgs; [
|
||||
cocogitto
|
||||
|
||||
|
|
Reference in New Issue