From 45f3830794bd1c1265d0faaee9a789f88d18e475 Mon Sep 17 00:00:00 2001 From: eric Date: Sun, 15 Mar 2026 17:14:25 +0100 Subject: [PATCH] ci: limit lefthook logging --- README.md | 1 + packages/repo-lib/lib.nix | 6 ++++++ template/flake.nix | 1 + tests/release.sh | 1 + 4 files changed, 9 insertions(+) diff --git a/README.md b/README.md index d19b524..8ebd370 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ outputs = { self, nixpkgs, repo-lib, ... }: - merged `packages` and `apps` from `perSystem` Checks are installed through `lefthook`, with `pre-commit` and `pre-push` commands configured to run in parallel. +repo-lib also sets Lefthook `output = [ "failure" "summary" ]` by default. For advanced Lefthook features, use raw `config.lefthook` or `perSystem.lefthook`. Those attrsets are merged after generated checks, so you can augment a generated command with fields that the simple `checks` abstraction does not carry, such as `stage_fixed`: diff --git a/packages/repo-lib/lib.nix b/packages/repo-lib/lib.nix index e92597f..86902f0 100644 --- a/packages/repo-lib/lib.nix +++ b/packages/repo-lib/lib.nix @@ -425,6 +425,12 @@ let inherit src; config = lib.foldl' lib.recursiveUpdate { } ( [ + { + output = [ + "failure" + "summary" + ]; + } (parallelHookStageConfig "pre-commit") (parallelHookStageConfig "pre-push") (lib.setAttrByPath [ "pre-commit" "commands" "treefmt" ] { diff --git a/template/flake.nix b/template/flake.nix index dbf4ad1..c2def80 100644 --- a/template/flake.nix +++ b/template/flake.nix @@ -53,6 +53,7 @@ # These checks become lefthook commands in the generated `lefthook.yml`. # repo-lib runs `pre-commit` and `pre-push` hook commands in parallel. + # It also sets `output = [ "failure" "summary" ]` by default. checks = { tests = { command = "echo 'No tests defined yet.'"; diff --git a/tests/release.sh b/tests/release.sh index 6deadac..3be5f44 100755 --- a/tests/release.sh +++ b/tests/release.sh @@ -1258,6 +1258,7 @@ run_mk_repo_lefthook_case() { run_capture_ok "$case_name: lefthook.yml derivation show failed" bash -c 'nix derivation show "$1" >"$2"' _ "$lefthook_yml_drv" "$lefthook_yml_json" assert_contains '\"pre-push\":{\"commands\":{\"tests\":{' "$lefthook_yml_json" "$case_name: generated check missing from pre-push" assert_contains 'repo-lib-check-tests' "$lefthook_yml_json" "$case_name: generated check command missing from lefthook config" + assert_contains '\"output\":[\"failure\",\"summary\"]' "$lefthook_yml_json" "$case_name: lefthook output config missing" assert_contains '\"stage_fixed\":true' "$lefthook_yml_json" "$case_name: stage_fixed missing from lefthook config" rm -rf "$workdir"