Skip to content

Commit 4a70f77

Browse files
authored
Merge pull request #985 from IntersectMBO/mgalazyn/chore/bump-ghc-add-devshell-hooks
nix: Add alejandra, prettify and cabal-gild git hook
2 parents cb3f550 + 3dc1a11 commit 4a70f77

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-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: 28 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,30 @@
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 = let
88+
script = nixpkgs.writeShellScript "precommit-cabal-gild" ''
89+
for file in "$@"; do
90+
cabal-gild --io="$file"
91+
done
92+
'';
93+
in
94+
builtins.toString script;
95+
files = "\\.cabal$";
96+
};
97+
prettify = {
98+
enable = true;
99+
entry = "scripts/githooks/haskell-style-lint";
100+
types = ["haskell"];
101+
};
102+
};
103+
};
104+
80105
# We use cabalProject' to ensure we don't build the plan for
81106
# all systems.
82107
cabalProject = nixpkgs.haskell-nix.cabalProject' ({config, ...}: {
@@ -104,6 +129,7 @@
104129
secure: True
105130
active-repositories: hackage.haskell.org, cardano-haskell-packages-local
106131
'';
132+
107133
shell.packages = p: [
108134
# Packages in this repo
109135
p.cardano-api
@@ -133,6 +159,8 @@
133159
# Skip cross compilers for the shell
134160
shell.crossPlatforms = _: [];
135161
shell.shellHook = ''
162+
export PATH="${nixpkgs.nix}/bin:$PATH"
163+
${pre-commit-check.shellHook}
136164
export LD_LIBRARY_PATH="${nixpkgs.snappy}/lib:$LD_LIBRARY_PATH"
137165
export PATH="$(git rev-parse --show-toplevel)/scripts/devshell:$PATH"
138166
'';

0 commit comments

Comments
 (0)