Configure git-hooks-nix

This commit is contained in:
Oliver Davies 2025-06-22 23:17:37 +01:00
parent 6d65e70fe3
commit 6c3ab477e0
6 changed files with 112 additions and 1 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
/.editorconfig
/.gitattributes
/.pre-commit-config.yaml
/drush
/html
/recipes

76
flake.lock generated
View file

@ -18,6 +18,22 @@
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
@ -36,6 +52,47 @@
"type": "github"
}
},
"git-hooks-nix": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1749636823,
"narHash": "sha256-WUaIlOlPLyPgz9be7fqWJA5iG6rHcGRtLERSCfUDne4=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "623c56286de5a3193aa38891a6991b28f9bab056",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks-nix",
"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": 1722073938,
@ -68,6 +125,22 @@
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1730768919,
"narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1744463964,
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
@ -87,7 +160,8 @@
"inputs": {
"devshell": "devshell",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_2"
"git-hooks-nix": "git-hooks-nix",
"nixpkgs": "nixpkgs_3"
}
}
},

View file

@ -1,7 +1,12 @@
{
inputs = {
devshell.url = "github:numtide/devshell";
flake-parts.url = "github:hercules-ci/flake-parts";
git-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
git-hooks-nix.url = "github:cachix/git-hooks.nix";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
@ -12,6 +17,7 @@
imports = [
./nix/modules/dev-shell.nix
./nix/modules/git-hooks.nix
];
perSystem =

16
nix/modules/git-hooks.nix Normal file
View file

@ -0,0 +1,16 @@
{ inputs, ... }:
{
imports = [
inputs.git-hooks-nix.flakeModule
./phpcs.nix
./phpstan.nix
];
perSystem =
{ config, ... }:
{
devshells.default.devshell.startup.git-hooks.text = config.pre-commit.installationScript;
};
}

7
nix/modules/phpcs.nix Normal file
View file

@ -0,0 +1,7 @@
{
perSystem.pre-commit.settings.hooks.phpcs = {
enable = true;
settings.binPath = "vendor/bin/phpcs";
};
}

7
nix/modules/phpstan.nix Normal file
View file

@ -0,0 +1,7 @@
{
perSystem.pre-commit.settings.hooks.phpstan = {
enable = true;
settings.binPath = "vendor/bin/phpstan";
};
}