Skip to content

Commit

Permalink
Enforce nixfmt check in pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
oxalica committed Mar 4, 2025
1 parent e76f2e3 commit 11e82b8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,30 @@ rec {
rustPkgs = rust-overlay.packages.${system};

pre-commit = pkgs.writeShellScriptBin "pre-commit" ''
set -e
set -eu
export PATH="$PATH''${PATH:+:}"${
lib.escapeShellArg (
lib.makeBinPath [
pkgs.nixfmt-rfc-style
pkgs.fd
pkgs.findutils
]
)
}
die() { echo "$*" >&2; exit 1; }
if git_dir="$(git rev-parse --show-toplevel)"; then
cd "$git_dir"
fi
cargo fmt --all --check \
|| die 'Format failed'
|| die 'cargo fmt failed'
fd -e nix --exclude=crates/syntax/test_data | xargs nixfmt --check \
|| die 'nixfmt failed'
cargo clippy --workspace --all-targets -- -Dwarnings \
|| die 'Clippy failed'
|| die 'clippy failed'
( cd editors/coc-nil; npm run lint )
cd editors/coc-nil && npm run lint
'';

in
Expand Down

0 comments on commit 11e82b8

Please sign in to comment.