Skip to content

Commit

Permalink
Use the module system, delegate activation to project.nix core
Browse files Browse the repository at this point in the history
New
 - Selectively enable tools (#2)
 - Make choice of tool versions overridable
 - User-definable hooks
 - Input validation at the Nix level

Fixes
 - Stop installing files all over the place when doing nix-shell ../some-project to borrow a tool
 - Lorri support

Cleanup
 - Get rid of installation code
  • Loading branch information
roberth committed Sep 25, 2019
1 parent e3661fe commit dc3c678
Show file tree
Hide file tree
Showing 6 changed files with 488 additions and 116 deletions.
24 changes: 18 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
repos:
- repo: .pre-commit-hooks/
rev: master
hooks:
- id: shellcheck
- id: canonix
# DO NOT MODIFY
# This file was generated by project.nix
{
"repos": [
{
"hooks": [
{
"id": "canonix"
},
{
"id": "shellcheck"
}
],
"repo": ".pre-commit-hooks/",
"rev": "master"
}
]
}
83 changes: 83 additions & 0 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{ config, lib, pkgs, ... }:
let
inherit (config.pre-commit) tools;
in {
config.pre-commit.hooks =
{
hlint =
{
name = "hlint";
description =
"HLint gives suggestions on how to improve your source code.";
entry = "${tools.hlint}/bin/hlint";
files = "\\.l?hs$";
};
ormolu =
{
name = "ormolu";
description = "Haskell code prettifier.";
entry = "${tools.ormolu}/bin/ormolu --mode inplace";
files = "\\.l?hs$";
};
hindent =
{
name = "hindent";
description = "Haskell code prettifier.";
entry = "${tools.hindent}/bin/hindent";
files = "\\.l?hs$";
};
cabal-fmt =
{
name = "cabal-fmt";
description = "Format Cabal files";
entry = "${tools.cabal-fmt}/bin/cabal-fmt --inplace";
files = "\\.cabal$";
};
canonix =
{
name = "canonix";
description = "Nix code prettifier.";
entry = "${tools.canonix}/bin/canonix";
files = "\\.nix$";
};
nixfmt =
{
name = "nixfmt";
description = "Nix code prettifier.";
entry = "${tools.nixfmt}/bin/nixfmt";
files = "\\.nix$";
};
nixpkgs-fmt =
{
name = "nixpkgs-fmt";
description = "Nix code prettifier.";
entry = "${tools.nixpkgs-fmt}/bin/nixpkgs-fmt -i";
files = "\\.nix$";
};
elm-format =
{
name = "elm-format";
description = "Format Elm files";
entry =
"${tools.elm-format}/bin/elm-format --yes --elm-version=0.19";
files = "\\.elm$";
};
shellcheck =
{
name = "shellcheck";
description = "Format shell files";
types =
[
"bash"
];
entry = "${tools.shellcheck}/bin/shellcheck";
};
terraform-format =
{
name = "terraform-format";
description = "Format terraform (.tf) files";
entry = "${tools.terraform-fmt}/bin/terraform-fmt";
files = "\\.tf$";
};
};
}
Loading

0 comments on commit dc3c678

Please sign in to comment.