Skip to content

Commit e659469

Browse files
committed
nix: Add alejandra, prettify and cabal-gild git hook
1 parent 8bba9fa commit e659469

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ tags
4747
/*.vkey
4848
/*.cert
4949

50+
.pre-commit-config.yaml
51+
5052
# For now require that users generate their own hie.yaml
5153
/hie.yaml
5254

flake.lock

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
nixpkgs.url = "github:NixOS/nixpkgs/4284c2b73c8bce4b46a6adf23e16d9e2ec8da4bb";
1717
iohkNix.url = "github:input-output-hk/iohk-nix";
1818
flake-utils.url = "github:hamishmack/flake-utils/hkm/nested-hydraJobs";
19+
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
1920
incl.url = "github:divnix/incl";
2021
# non-flake nix compatibility
2122
flake-compat = {
@@ -77,6 +78,23 @@
7778
proto-js-bundle-drv = import ./nix/proto-to-js.nix {pkgs = nixpkgs;};
7879
wasm-typedoc-drv = import ./nix/typedoc.nix {pkgs = nixpkgs;};
7980

81+
pre-commit-check = inputs.pre-commit-hooks.lib.${nixpkgs.system}.run {
82+
src = ./.;
83+
hooks = {
84+
alejandra.enable = true;
85+
cabal-gild = {
86+
enable = true;
87+
entry = "cabal-gild";
88+
files = "\\.cabal$";
89+
};
90+
prettify = {
91+
enable = true;
92+
entry = "scripts/githooks/haskell-style-lint";
93+
types = ["haskell"];
94+
};
95+
};
96+
};
97+
8098
# We use cabalProject' to ensure we don't build the plan for
8199
# all systems.
82100
cabalProject = nixpkgs.haskell-nix.cabalProject' ({config, ...}: {
@@ -104,6 +122,7 @@
104122
secure: True
105123
active-repositories: hackage.haskell.org, cardano-haskell-packages-local
106124
'';
125+
107126
shell.packages = p: [
108127
# Packages in this repo
109128
p.cardano-api
@@ -133,6 +152,8 @@
133152
# Skip cross compilers for the shell
134153
shell.crossPlatforms = _: [];
135154
shell.shellHook = ''
155+
export PATH="${nixpkgs.nix}/bin:$PATH"
156+
${pre-commit-check.shellHook}
136157
export LD_LIBRARY_PATH="${nixpkgs.snappy}/lib:$LD_LIBRARY_PATH"
137158
export PATH="$(git rev-parse --show-toplevel)/scripts/devshell:$PATH"
138159
'';

0 commit comments

Comments
 (0)