diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..317680c --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +nix fmt . +git diff --exit-code || { + echo "Formatter changed files — review with 'git diff', then re-stage and commit." + exit 1 +} diff --git a/modules/shell/git.nix b/modules/shell/git.nix index 8331f4b..3c70752 100644 --- a/modules/shell/git.nix +++ b/modules/shell/git.nix @@ -10,13 +10,12 @@ programs = { git = { enable = true; - hooks.pre-commit = pkgs.writeShellScript "pre-commit" '' - nix fmt . - git diff --exit-code || { - echo "Formatter changed files — review with 'git diff', then re-stage and commit." - exit 1 + includes = [ + { + condition = "gitdir:~/.setup/"; + contents.core.hooksPath = "~/.setup/.githooks"; } - ''; + ]; settings = { user.name = "Kabbone"; user.email = "tobias@opel-online.de";