File tree Expand file tree Collapse file tree 9 files changed +116
-7
lines changed Expand file tree Collapse file tree 9 files changed +116
-7
lines changed Original file line number Diff line number Diff line change
1
+ use flake .# default
Original file line number Diff line number Diff line change @@ -28,3 +28,4 @@ cabal.project.local
28
28
cabal.project.local~
29
29
.HTF /
30
30
.ghc.environment. *
31
+ .direnv /
Original file line number Diff line number Diff line change 5
5
{
6
6
imports =
7
7
[
8
+ ./pre-commit.nix
8
9
./haskell-flake-project/build.nix
9
10
./rust-flake-project/build.nix
10
11
./typescript-flake-project/build.nix
Original file line number Diff line number Diff line change
1
+ { inputs , config , ... } : {
2
+ imports = [
3
+ inputs . pre-commit-hooks . flakeModule
4
+ config . flake-lang . rustMonorepoPreCommit
5
+ config . flake-lang . denoPreCommit
6
+ ] ;
7
+ perSystem = _ : {
8
+ pre-commit . settings = {
9
+ hooks = {
10
+ rust-monorepo . enable = true ;
11
+ my-deno . enable = true ;
12
+ } ;
13
+ } ;
14
+ } ;
15
+ }
Original file line number Diff line number Diff line change 1
- # Note(jaredponn):
2
-
1
+ # NOTE(jaredponn):
3
2
# Loosely, the key idea is that in this flake we want to have an attribute like
4
3
# ```
5
4
# lib.<system> = {
10
9
# };
11
10
# ```
12
11
# This is unfortunately not super easy to do with flake-parts! Some useful
13
- # links + examples are as follows.
12
+ # links + examples are as follows.
14
13
# - [1] https://github.com/hercules-ci/flake-parts/blob/main/lib.nix
15
14
# - [2] https://github.com/hercules-ci/flake-parts/pull/63/files
16
15
# - [3] https://github.com/hercules-ci/flake-parts/blob/main/modules/formatter.nix
79
78
default = import ./typescript/flake-typescript.nix pkgs ;
80
79
readOnly = true ;
81
80
description = lib . mdDoc builtins . readFile ./typescript/description.md ;
82
- # TODO(jaredponn): add an example
83
- # example = lib.mdDoc '' '';
81
+ example = lib . mdDoc ''TODO(jaredponn)'' ;
82
+ } ;
83
+
84
+ rustMonorepoPreCommit = lib . mkOption {
85
+ type = lib . types . flakeModule ;
86
+ default = ./pre-commit-hooks/rust-monorepo.nix ;
87
+ readOnly = true ;
88
+ description = lib . mdDoc ''pre-commit-hooks.nix hook for Rust in a monorepo setting'' ;
89
+ example = lib . mdDoc ''TODO(bladyjoker)'' ;
90
+ } ;
91
+
92
+ denoPreCommit = lib . mkOption {
93
+ type = lib . types . flakeModule ;
94
+ default = ./pre-commit-hooks/deno.nix ;
95
+ readOnly = true ;
96
+ description = lib . mdDoc ''pre-commit-hooks.nix hook for Deno in a monorepo setting'' ;
97
+ example = lib . mdDoc ''TODO(bladyjoker)'' ;
84
98
} ;
85
99
86
100
} ;
Original file line number Diff line number Diff line change
1
+ { inputs , ... } : {
2
+ imports = [
3
+ inputs . pre-commit-hooks . flakeModule # Adds perSystem.pre-commit options
4
+ ./tools.nix
5
+ ] ;
6
+ perSystem = { config , ... } :
7
+ {
8
+ pre-commit . settings . hooks = {
9
+ # TODO(jaredponn): Why do we use our strange version of `denofmt` and
10
+ # `denolint`? The default implemented version in `pre-commit-hooks.nix`
11
+ # is a bit buggy (see
12
+ # https://github.com/cachix/pre-commit-hooks.nix/issues/374), and the
13
+ # latest version of `deno` on nix doesn't allow explicitly applying
14
+ # the formatter to specific files
15
+ my-denofmt =
16
+ {
17
+ name = "denofmt" ;
18
+ description = "Format Typescript code." ;
19
+ entry = "${ config . flake-lang . pre-commit-hooks . tools . deno } /bin/deno fmt" ;
20
+ files = "(\\ .m?ts$)|(^tsconfig?(-base)\\ .json$)" ;
21
+ } ;
22
+
23
+ my-denolint =
24
+ {
25
+ name = "denolint" ;
26
+ description = "Lint Typescript code." ;
27
+ entry = "${ config . flake-lang . pre-commit-hooks . tools . deno } /bin/deno lint" ;
28
+ files = "\\ .m?ts$" ;
29
+ } ;
30
+
31
+ } ;
32
+ } ;
33
+ }
Original file line number Diff line number Diff line change
1
+ { inputs , ... } : {
2
+ imports = [
3
+ inputs . pre-commit-hooks . flakeModule # Adds perSystem.pre-commit options
4
+ ./tools.nix
5
+ ] ;
6
+ perSystem = { config , ... } :
7
+ {
8
+ pre-commit . settings . hooks = {
9
+ rustfmt-monorepo =
10
+ {
11
+ name = "rustfmt" ;
12
+ description = "Format Rust code." ;
13
+ entry = "${ config . flake-lang . pre-commit-hooks . tools . rustfmt } /bin/rustfmt --color always" ;
14
+ files = "\\ .rs$" ;
15
+ } ;
16
+
17
+ } ;
18
+ } ;
19
+ }
Original file line number Diff line number Diff line change
1
+ { flake-parts-lib , lib , ... } : {
2
+ perSystem = flake-parts-lib . mkPerSystemOption ( { pkgs , pkgsForRust , ... } : {
3
+ options = {
4
+ flake-lang . pre-commit-hooks . tools = {
5
+
6
+ rustfmt = lib . mkOption {
7
+ type = lib . types . derivation ;
8
+ default = pkgsForRust . rustfmt ;
9
+ readOnly = false ;
10
+ description = lib . mdDoc ''Rust formatter to use for pre-commit hooks'' ;
11
+ } ;
12
+
13
+ deno = lib . mkOption {
14
+ type = lib . types . derivation ;
15
+ default = pkgs . deno ;
16
+ readOnly = false ;
17
+ description = lib . mdDoc ''Deno tool to use for pre-commit hooks'' ;
18
+ } ;
19
+
20
+ } ;
21
+ } ;
22
+ } ) ;
23
+ }
Original file line number Diff line number Diff line change 1
1
{ inputs , ... } : {
2
- imports = [ inputs . pre-commit-hooks . flakeModule ] ;
2
+ imports = [
3
+ inputs . pre-commit-hooks . flakeModule
4
+ ] ;
3
5
perSystem = { config , ... } : {
4
- devShells . dev-pre-commit = config . pre-commit . devShell ;
6
+ devShells . default = config . pre-commit . devShell ;
5
7
pre-commit . settings = {
6
8
hooks = {
7
9
# Typos
You can’t perform that action at this time.
0 commit comments