From b70bbbe680ff5f5ab6e35a21a091d0f845278cda Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 7 Jun 2025 15:09:24 +0200 Subject: [PATCH] misc/pre-commit: add automatic `clang-format` of changed lines Lix has a style guide: https://wiki.lix.systems/books/lix-contributors/page/code but contributors like me have been unable to enforce it, which is sad. To avoid further violations of that style guide, we enable a pre-commit hook for clang formatting of the changed lines. Change-Id: I217452efa3ac8bd66b4d3a08a6fe9a241207790b Signed-off-by: Raito Bezarius --- misc/pre-commit.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/misc/pre-commit.nix b/misc/pre-commit.nix index 3d0c551fe..2a400fd13 100644 --- a/misc/pre-commit.nix +++ b/misc/pre-commit.nix @@ -32,6 +32,21 @@ pre-commit-run { enable = true; settings.branch = [ "main" ]; }; + clang-format = { + enable = true; + package = pkgs.llvmPackages.libclang.python; + entry = "${pkgs.llvmPackages.libclang.python}/bin/git-clang-format"; + files = "^(lix/|tests/)"; + types = [ + "c++" + "file" + ]; + excludes = [ + ''^lix/pch/.*$'' + ''\.gen\.hh$'' + ]; + pass_filenames = false; # this will automatically format everything in the stage area of Git. + }; check-case-conflicts.enable = true; check-executables-have-shebangs = { enable = true;