Skip to content

Commit 0e9bf3e

Browse files
authored
Merge pull request #638 from dwoffinden/hledger-fmt
Add hledger-fmt hook
2 parents 59cc725 + b259f83 commit 0e9bf3e

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ use nix
503503
- [end-of-file-fixer](https://github.com/pre-commit/pre-commit-hooks/blob/main/pre_commit_hooks/end_of_file_fixer.py)
504504
- [fix-byte-order-marker](https://github.com/pre-commit/pre-commit-hooks/blob/main/pre_commit_hooks/fix_byte_order_marker.py)
505505
- [headache](https://github.com/frama-c/headache)
506+
- [hledger-fmt](https://github.com/mondeja/hledger-fmt)
506507
- [mixed-line-endings](https://github.com/pre-commit/pre-commit-hooks/blob/main/pre_commit_hooks/mixed_line_ending.py)
507508
- [mkdocs-linkcheck](https://github.com/byrnereese/linkchecker-mkdocs)
508509
- [openapi-spec-validator](https://github.com/python-openapi/openapi-spec-validator)

modules/hooks.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,20 @@ in
680680
};
681681
};
682682
};
683+
hledger-fmt = mkOption {
684+
description = "hledger-fmt hook";
685+
type = types.submodule {
686+
imports = [ hookModule ];
687+
options.settings = {
688+
fix =
689+
mkOption {
690+
type = types.bool;
691+
description = "Fix the files in place.";
692+
default = false;
693+
};
694+
};
695+
};
696+
};
683697
hlint = mkOption {
684698
description = "hlint hook";
685699
type = types.submodule {
@@ -3101,6 +3115,22 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
31013115
entry = "${hooks.hindent.package}/bin/hindent";
31023116
files = "\\.l?hs(-boot)?$";
31033117
};
3118+
hledger-fmt =
3119+
{
3120+
name = "hledger-fmt";
3121+
description = "Opinionated hledger's journal files formatter.";
3122+
package = tools.hledger-fmt;
3123+
entry =
3124+
let
3125+
cmdArgs = mkCmdArgs (
3126+
with hooks.hledger-fmt.settings; [
3127+
[ fix "--fix" ]
3128+
]
3129+
);
3130+
in
3131+
"${hooks.hledger-fmt.package}/bin/hledger-fmt ${cmdArgs}";
3132+
files = "\\.(hledger|journal|j)$";
3133+
};
31043134
hlint =
31053135
{
31063136
name = "hlint";

nix/tools.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
, hadolint
4141
, haskellPackages
4242
, hindent
43+
, hledger-fmt ? null
4344
, hlint
4445
, hpack
4546
, html-tidy
@@ -149,6 +150,7 @@ in
149150
gptcommit
150151
hadolint
151152
hindent
153+
hledger-fmt
152154
hlint
153155
hpack
154156
html-tidy

0 commit comments

Comments
 (0)