let
  sources = import ./default.nix;
  pkgs = import sources.nixpkgs { };
  pre-commit = import sources.git-hooks;

  globalExcludes = [
    "nix/default.nix"
    "attic"
    "vcluster"
    ".*vendor"
    ".*chart/.*"
    ".*schema.json"
  ];

in
pre-commit.run {
  src = pkgs.nix-gitignore.gitignoreSource [ ] ../.;
  # Do not run at pre-commit time
  default_stages = [
    "pre-push"
  ];
  # TODO(mrtz): Remove when default
  package = pkgs.prek;
  # Linters From https://github.com/cachix/pre-commit-hooks.nix
  hooks = {
    nixfmt-rfc-style = {
      enable = true;
      excludes = globalExcludes;
    };

    trim-trailing-whitespace.enable = true;

    shellcheck = {
      enable = true;
      excludes = [
        "vcluster/"
        "attic/"
      ];
      args = [
        "-x"
        "-o"
        "all"
      ];
    };

    yamllint = {
      enable = true;
      excludes = [
        "attic/"
        "charts/templates/"
        "charts/"
        "values/"
        "vcluster/"
      ];
      settings = {
        strict = true;
        configData = ''{ extends: default, rules: { document-start: disable, line-length: {max: 300} } }'';
      };
    };

    check-json.enable = true;

    renovate-config-validator = {
      enable = true;
      files = "renovate.json$";
      entry = "renovate-config-validator";
    };

  };
}
