Skip to content

Commit

Permalink
add gptcommit
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Apr 5, 2023
1 parent 3342d7c commit da8ed83
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ clang-format = {
## Git

- [commitizen](https://github.com/commitizen-tools/commitizen)
- [gptcommit](https://github.com/zurawiki/gptcommit)

## Custom hooks

Expand Down
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

outputs = { self, nixpkgs, flake-utils, gitignore, nixpkgs-stable, ... }:
let
lib = nixpkgs.lib;
defaultSystems = [
"aarch64-linux"
"aarch64-darwin"
Expand Down Expand Up @@ -46,7 +47,8 @@
inherit (exposed.checks.pre-commit-check) shellHook;
};

checks = exposed.checks // exposed-stable.checks;
checks = lib.filterAttrs (k: v: v != null)
(exposed.checks // exposed-stable.checks);

lib = { inherit (exposed) run; };
}
Expand Down
13 changes: 13 additions & 0 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,19 @@ in
## the `dune-project` file has changed.
pass_filenames = false;
};
gptcommit = lib.optionalAttrs (tools.gptcommit != null) {
name = "gptcommit";
description = "Generate a commit message using GPT3.";
entry =
let
script = pkgs.writeShellScript "precommit-gptcomit" ''
${tools.gptcommit}/bin/gptcommit prepare-commit-msg --commit-source \
"$PRE_COMMIT_COMMIT_MSG_SOURCE" --commit-msg-file "$1"
'';
in
toString script;
stages = [ "prepare-commit-msg" ];
};
hlint =
{
name = "hlint";
Expand Down
2 changes: 1 addition & 1 deletion modules/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ in

tools =
mkOption {
type = types.lazyAttrsOf types.package;
type = types.lazyAttrsOf (types.nullOr types.package);
description = lib.mdDoc
''
Tool set from which `nix-pre-commit-hooks` will pick binaries.
Expand Down
3 changes: 2 additions & 1 deletion nix/tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
, elmPackages
, git
, gitAndTools
, gptcommit ? null
, hadolint
, haskell
, haskellPackages
Expand Down Expand Up @@ -61,7 +62,7 @@ let
};
in
{
inherit actionlint ansible-lint alejandra cabal-fmt cabal2nix cargo clang-tools clippy deadnix dhall editorconfig-checker hadolint hindent hlint hpack html-tidy nil nixfmt nixpkgs-fmt opam ormolu rustfmt shellcheck shfmt statix stylish-haskell stylua tagref typos go mdsh revive go-tools yamllint ruff;
inherit actionlint ansible-lint alejandra cabal-fmt cabal2nix cargo clang-tools gptcommit clippy deadnix dhall editorconfig-checker hadolint hindent hlint hpack html-tidy nil nixfmt nixpkgs-fmt opam ormolu rustfmt shellcheck shfmt statix stylish-haskell stylua tagref typos go mdsh revive go-tools yamllint ruff;
inherit (elmPackages) elm-format elm-review elm-test;
# TODO: these two should be statically compiled
inherit (haskellPackages) fourmolu;
Expand Down

0 comments on commit da8ed83

Please sign in to comment.