forked from clan/clan-core
add pre-commit check
make sure things are sane before they hit CI, re-purposing the existing
treefmt configuration.
this adds a custom installer for pre-commit hooks, which is inspired by
pre-commit.nix[0], but is much more minimal than the underlying
pre-commit[1] and builds on a historic idea[2] from this repository.
[0]: https://github.com/cachix/git-hooks.nix
[1]: https://github.com/pre-commit/pre-commit
[2]: 930923512c
This commit is contained in:
parent
4b07bf363b
commit
055b17c01b
10
devShell.nix
10
devShell.nix
@ -1,3 +1,4 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
perSystem =
|
||||
{
|
||||
@ -8,6 +9,7 @@
|
||||
}:
|
||||
let
|
||||
writers = pkgs.callPackage ./pkgs/builders/script-writers.nix { };
|
||||
inherit (pkgs.callPackage inputs.git-hooks { }) lib;
|
||||
|
||||
ansiEscapes = {
|
||||
reset = ''\033[0m'';
|
||||
@ -20,6 +22,11 @@
|
||||
select-shell = writers.writePython3Bin "select-shell" {
|
||||
flakeIgnore = [ "E501" ];
|
||||
} ./pkgs/scripts/select-shell.py;
|
||||
|
||||
# run treefmt before each commit
|
||||
install-pre-commit-hook =
|
||||
with lib.git-hooks;
|
||||
pre-commit (wrap.abort-on-change config.treefmt.build.wrapper);
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
@ -34,8 +41,7 @@
|
||||
config.treefmt.build.wrapper
|
||||
];
|
||||
shellHook = ''
|
||||
# no longer used
|
||||
rm -f "$(git rev-parse --show-toplevel)/.git/hooks/pre-commit"
|
||||
${install-pre-commit-hook}
|
||||
|
||||
echo -e "${ansiEscapes.green}switch to another dev-shell using: select-shell${ansiEscapes.reset}"
|
||||
'';
|
||||
|
17
flake.lock
17
flake.lock
@ -40,6 +40,22 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"git-hooks": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1716413087,
|
||||
"narHash": "sha256-nSTIB7JeJGBGsvtqlyfhUByh/isyK1nfOq2YMxUOFJQ=",
|
||||
"owner": "fricklerhandwerk",
|
||||
"repo": "git-hooks",
|
||||
"rev": "99a78fcf7dc03ba7b1d5c00af109c1e28ced3490",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "fricklerhandwerk",
|
||||
"repo": "git-hooks",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixlib": {
|
||||
"locked": {
|
||||
"lastModified": 1712450863,
|
||||
@ -133,6 +149,7 @@
|
||||
"inputs": {
|
||||
"disko": "disko",
|
||||
"flake-parts": "flake-parts",
|
||||
"git-hooks": "git-hooks",
|
||||
"nixos-generators": "nixos-generators",
|
||||
"nixos-images": "nixos-images",
|
||||
"nixpkgs": "nixpkgs",
|
||||
|
Loading…
Reference in New Issue
Block a user