Skip to content

Commit

Permalink
Add default packages
Browse files Browse the repository at this point in the history
  • Loading branch information
sandydoo committed Feb 10, 2024
1 parent cd27f48 commit 91660e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let
cfg = config;
hooks = config.hooks;
settings = config.settings;
inherit (lib) mkOption mkRenamedOptionModule types;
inherit (lib) mkDefault mkOption mkRenamedOptionModule types;

hookModule =
[
Expand Down Expand Up @@ -2250,7 +2250,8 @@ in
{
name = "nixpkgs-fmt";
description = "Nix code prettifier.";
entry = "${tools.nixpkgs-fmt}/bin/nixpkgs-fmt";
package = tools.nixpkgs-fmt;
entry = "${hooks.nixpkgs-fmt.package}/bin/nixpkgs-fmt";
files = "\\.nix$";
};
ocp-indent =
Expand Down Expand Up @@ -2499,26 +2500,29 @@ in
name = "shellcheck";
description = "Format shell files.";
types = [ "shell" ];
entry = "${tools.shellcheck}/bin/shellcheck";
package = tools.shellcheck;
entry = "${hooks.shellcheck.package}/bin/shellcheck";
};
shfmt =
{
name = "shfmt";
description = "Format shell files.";
types = [ "shell" ];
entry = "${tools.shfmt}/bin/shfmt -w -s -l";
package = tools.shfmt;
entry = "${hooks.shfmt.package}/bin/shfmt -w -s -l";
};
staticcheck =
{
name = "staticcheck";
description = "State of the art linter for the Go programming language";
package = tools.go-tools;
# staticheck works with directories.
entry =
let
script = pkgs.writeShellScript "precommit-staticcheck" ''
err=0
for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do
${tools.go-tools}/bin/staticcheck ./"$dir"
${hooks.staticcheck.package}/bin/staticcheck ./"$dir"
code="$?"
if [[ "$err" -eq 0 ]]; then
err="$code"
Expand Down Expand Up @@ -2619,6 +2623,7 @@ in
description = "One CLI to format the code tree.";
types = [ "file" ];
pass_filenames = true;
package = mkDefault pkgs.treefmt;
entry = "${hooks.treefmt.package}/bin/treefmt --fail-on-change";
};
typos =
Expand Down Expand Up @@ -2676,6 +2681,7 @@ in
name = "yamllint";
description = "Yaml linter.";
types = [ "file" "yaml" ];
package = tools.yamllint;
entry =
let
cmdArgs =
Expand All @@ -2684,7 +2690,7 @@ in
[ (hooks.yamllint.settings.configPath != "") "-c ${hooks.yamllint.settings.configPath}" ]
];
in
"${tools.yamllint}/bin/yamllint ${cmdArgs}";
"${hooks.yamllint.package}/bin/yamllint ${cmdArgs}";
};
zprint =
{
Expand Down
1 change: 1 addition & 0 deletions nix/run.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let
{
_module.args.pkgs = pkgs;
_module.args.gitignore-nix-src = gitignore-nix-src;
_module.args.default_stages = default_stages;
inherit hooks excludes default_stages settings;
tools = builtinStuff.tools // tools;
package = pre-commit;
Expand Down

0 comments on commit 91660e9

Please sign in to comment.