yourevalid 0.2.0-alpha.2

Validation type and trait. For internal use in polyproto-related crates, currently
Documentation
{ git-hooks }:
{ config, lib, ... }:

let
  cfg = config.polyphony.gitHooks;
  rustCfg = config.polyphony.rust;
  treefmtCfg = config.polyphony.treefmt;
in

{
  imports = [
    git-hooks.flakeModule
  ];

  options.polyphony.gitHooks =
    let
      inherit (lib) mkEnableOption;
    in
    {
      enable =
        (mkEnableOption "automatic pre-commit hooks to ensure code is formatted, and passes linting checks")
        // {
          default = true;
          example = false;
        };
    };

  config.perSystem = lib.mkMerge [
    (lib.mkIf cfg.enable (
      { config, ... }:
      {
        pre-commit.settings.hooks = {
          clippy = {
            inherit (rustCfg) enable;
            packageOverrides = {
              cargo = config.polyphony.rust.toolchain;
              clippy = config.polyphony.rust.toolchain;
            };
          };

          treefmt = {
            inherit (treefmtCfg) enable;
            package = config.treefmt.build.wrapper;
          };
        };
      }
    ))
    (lib.mkIf (!cfg.enable) {
      pre-commit.check.enable = false;
    })
  ];
}