Skip to content

Commit ea37f78

Browse files
committed
refactor(overview): make nix-config more readable
and fix `toPretty`, which is defined under `generators`.
1 parent 37d4af4 commit ea37f78

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

overview/content-types/nix-config.nix

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
{
22
lib,
33
config,
4-
options,
54
modulesPath,
65
pkgs,
7-
utils,
86
...
97
}:
108
let
11-
inherit (lib) mkOption types;
9+
inherit (lib)
10+
mkOption
11+
types
12+
;
1213
in
1314
{
1415
options =
1516
let
16-
nix-module = import (modulesPath + "/config/nix.nix") {
17-
inherit config lib pkgs;
18-
};
17+
nix-module = import (modulesPath + "/config/nix.nix") { inherit config lib pkgs; };
18+
nixOpts = nix-module.options.nix.settings.type.getSubOptions { };
1919
in
2020
{
21-
inherit (nix-module.options) nix;
22-
21+
settings = mkOption {
22+
type = types.submodule {
23+
options = {
24+
inherit (nixOpts)
25+
substituters
26+
trusted-public-keys
27+
;
28+
};
29+
};
30+
};
2331
__toString = mkOption {
2432
type = with types; functionTo str;
2533
readOnly = true;
@@ -48,7 +56,7 @@ in
4856
else if strings.isConvertibleWithToString v then
4957
toString v
5058
else
51-
abort "The nix conf value: ${toPretty { } v} can not be encoded";
59+
abort "The nix conf value: ${generators.toPretty { } v} can not be encoded";
5260

5361
mkKeyValue = k: v: "${escape [ "=" ] k} = ${mkValueString v}";
5462

@@ -61,19 +69,5 @@ in
6169
${mkKeyValuePairs (filterAttrs (key: value: isExtra key) self.settings)}
6270
'';
6371
};
64-
settings = mkOption {
65-
type = types.submodule {
66-
options =
67-
let
68-
nixOpts = options.nix.settings.type.getSubOptions { };
69-
in
70-
{
71-
inherit (nixOpts)
72-
substituters
73-
trusted-public-keys
74-
;
75-
};
76-
};
77-
};
7872
};
7973
}

0 commit comments

Comments
 (0)