Skip to content

Commit 8ce7fdd

Browse files
authored
refactor to avoid nested submodules (#32)
1 parent 07defbd commit 8ce7fdd

File tree

1 file changed

+49
-43
lines changed

1 file changed

+49
-43
lines changed

flake-module.nix

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,42 @@ in
1616
{
1717
options = {
1818
perSystem = mkPerSystemOption
19-
({ config, self', inputs', pkgs, system, ... }: {
20-
options.haskellProjects = mkOption {
21-
description = "Haskell projects";
22-
type = types.attrsOf (types.submodule {
19+
({ config, self', inputs', pkgs, system, ... }:
20+
let
21+
hlsCheckSubmodule = types.submodule {
22+
options = {
23+
enable = mkOption {
24+
type = types.bool;
25+
description = ''
26+
Whether to enable a flake check to verify that HLS works.
27+
28+
This is equivalent to `nix develop -i -c haskell-language-server`.
29+
30+
Note that, HLS will try to access the network through Cabal (see
31+
https://github.com/haskell/haskell-language-server/issues/3128),
32+
therefore sandboxing must be disabled when evaluating this
33+
check.
34+
'';
35+
default = false;
36+
};
37+
38+
};
39+
};
40+
hlintCheckSubmodule = types.submodule {
41+
options = {
42+
enable = mkOption {
43+
type = types.bool;
44+
description = "Whether to add a flake check to run hlint";
45+
default = false;
46+
};
47+
dirs = mkOption {
48+
type = types.listOf types.str;
49+
description = "Relative path strings from `root` to directories that should be checked with hlint";
50+
default = [ "." ];
51+
};
52+
};
53+
};
54+
projectSubmodule = types.submodule {
2355
options = {
2456
haskellPackages = mkOption {
2557
type = types.attrsOf raw;
@@ -75,47 +107,21 @@ in
75107
};
76108
hlsCheck = mkOption {
77109
default = { };
78-
type = types.submodule {
79-
options = {
80-
enable = mkOption {
81-
type = types.bool;
82-
description = ''
83-
Whether to enable a flake check to verify that HLS works.
84-
85-
This is equivalent to `nix develop -i -c haskell-language-server`.
86-
87-
Note that, HLS will try to access the network through Cabal (see
88-
https://github.com/haskell/haskell-language-server/issues/3128),
89-
therefore sandboxing must be disabled when evaluating this
90-
check.
91-
'';
92-
default = false;
93-
};
94-
95-
};
96-
};
97-
};
98-
hlintCheck = mkOption {
99-
default = { };
100-
type = types.submodule {
101-
options = {
102-
enable = mkOption {
103-
type = types.bool;
104-
description = "Whether to add a flake check to run hlint";
105-
default = false;
106-
};
107-
dirs = mkOption {
108-
type = types.listOf types.str;
109-
description = "Relative path strings from `root` to directories that should be checked with hlint";
110-
default = [ "." ];
111-
};
112-
};
113-
};
110+
type = hlsCheckSubmodule;
114111
};
115112
};
116-
});
117-
};
118-
});
113+
hlintCheck = mkOption {
114+
default = { };
115+
type = hlintCheckSubmodule;
116+
};
117+
};
118+
in
119+
{
120+
options.haskellProjects = mkOption {
121+
description = "Haskell projects";
122+
type = types.attrsOf projectSubmodule;
123+
};
124+
});
119125
};
120126
config = {
121127
perSystem = { config, self', inputs', pkgs, ... }:

0 commit comments

Comments
 (0)