the-algorithm/pre-commit-hooks.nix
Aaron Siddhartha Mondal eaae3e286e
❄️ Add Nix flake and pre-commit hooks
Setting up the different tools for development can be hard for new
contributors. This commit adds a Nix flake that provides a reproducible
development environment which is easy to set up and ensures consistent
code style across all subprojects.

The initial flake contains `git`, `pre-commit`, `which` and `bazelisk`
wrapped as a `bazel` executable. Dependencies like Rust, Scala etc may
be added in the `packages` attribute in the future.

The current pre-commit configuration is a no-op. Future commits may
enable the currently disabled parts of `pre-commit-hooks.nix` for a
gradual transition.

Supports `(x86_64|aarch64) (Linux|MacOS)` systems.
2023-04-01 03:26:02 +02:00

75 lines
2.0 KiB
Nix

{ pkgs, ... }:
{
# Default hooks
# trailing-whitespace-fixer = {
# enable = true;
# name = "trailing-whitespace";
# description = "Remove trailing whitespace";
# entry = "${pkgs.python311Packages.pre-commit-hooks}/bin/trailing-whitespace-fixer";
# types = [ "text" ];
# };
# end-of-file-fixer = {
# enable = true;
# name = "end-of-file-fixer";
# description = "Remove trailing whitespace";
# entry = "${pkgs.python311Packages.pre-commit-hooks}/bin/end-of-file-fixer";
# excludes = [ "png" ];
# types = [ "text" ];
# };
fix-byte-order-marker = {
enable = true;
name = "fix-byte-order-marker";
entry = "${pkgs.python311Packages.pre-commit-hooks}/bin/fix-byte-order-marker";
types = [ "text" ];
};
mixed-line-ending = {
enable = true;
name = "mixed-line-ending";
entry = "${pkgs.python311Packages.pre-commit-hooks}/bin/mixed-line-ending";
excludes = [ "png" ];
types = [ "text" ];
};
check-case-conflict = {
enable = true;
name = "check-case-conflict";
entry = "${pkgs.python311Packages.pre-commit-hooks}/bin/check-case-conflict";
types = [ "text" ];
};
detect-private-key = {
enable = true;
name = "detect-private-key";
entry = "${pkgs.python311Packages.pre-commit-hooks}/bin/detect-private-key";
types = [ "text" ];
};
# Starlark
# bazel-buildifier-format = {
# enable = true;
# name = "buildifier format";
# description = "Format Starlark";
# entry = "${pkgs.bazel-buildtools}/bin/buildifier";
# types = [ "bazel" ];
# };
# bazel-buildifier-lint = {
# enable = true;
# name = "buildifier lint";
# description = "Lint Starlark";
# entry = "${pkgs.bazel-buildtools}/bin/buildifier -lint=warn";
# types = [ "bazel" ];
# };
# YAML
# yamllint = {
# enable = true;
# };
# Nix
nixpkgs-fmt.enable = true;
# Markdown
# markdownlint = {
# enable = true;
# types = [ "markdown" ];
# };
}