build: add shared hook config

Replace the ignored devenv-generated pre-commit symlink with a tracked PATH-based prek config and local large-file hook so both devenv and Guix shells can run commit and push hooks.
This commit is contained in:
2026-06-01 16:21:19 +02:00
parent b048a370d2
commit 381fb95eac
3 changed files with 61 additions and 3 deletions
-3
View File
@@ -27,8 +27,5 @@ devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml
# Local runtime artifacts
/.state/
+23
View File
@@ -0,0 +1,23 @@
# Shared by Nix/devenv and Guix shells. Keep hook entries PATH-based.
default_stages:
- pre-commit
repos:
- repo: local
hooks:
- id: check-added-large-files
name: check added large files
entry: scripts/hooks/check-added-large-files
args: ["--maxkb=16384"]
language: system
types: [file]
stages: [pre-commit, pre-push, manual]
- id: npm-format-check
name: npm format check
entry: npm run format:check
language: system
pass_filenames: false
files: '\.(cjs|js|json|md|mjs|ts|tsx|yaml|yml)$'
types: [text]
stages: [pre-commit]
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env sh
set -eu
maxkb=500
while [ "$#" -gt 0 ]; do
case "$1" in
--maxkb=*)
maxkb=${1#--maxkb=}
shift
;;
--)
shift
break
;;
-*)
echo "check-added-large-files: unknown option: $1" >&2
exit 2
;;
*)
break
;;
esac
done
limit=$((maxkb * 1024))
failed=0
for file in "$@"; do
[ -f "$file" ] || continue
size=$(wc -c < "$file" | tr -d '[:space:]')
if [ "$size" -gt "$limit" ]; then
kb=$(((size + 1023) / 1024))
echo "$file (${kb} KB) exceeds ${maxkb} KB" >&2
failed=1
fi
done
exit "$failed"