···
cfg = config.services.stargazer;
7
-
routesFormat = pkgs.formats.ini { };
8
-
globalFile = pkgs.writeText "global.ini" ''
9
-
listen = ${concatStringsSep " " cfg.listen}
10
-
connection-logging = ${boolToString cfg.connectionLogging}
11
-
log-ip = ${boolToString cfg.ipLog}
12
-
log-ip-partial = ${boolToString cfg.ipLogPartial}
8
+
listen = ${lib.concatStringsSep " " cfg.listen}
9
+
connection-logging = ${lib.boolToString cfg.connectionLogging}
10
+
log-ip = ${lib.boolToString cfg.ipLog}
11
+
log-ip-partial = ${lib.boolToString cfg.ipLogPartial}
request-timeout = ${toString cfg.requestTimeout}
response-timeout = ${toString cfg.responseTimeout}
···
${optionalString (cfg.certLifetime != "") "cert-lifetime = ${cfg.certLifetime}"}
24
-
routesFile = routesFormat.generate "router.ini" cfg.routes;
25
-
configFile = pkgs.runCommand "config.ini" { } ''
26
-
cat ${globalFile} ${routesFile} > $out
23
+
genINI = lib.generators.toINI { };
24
+
configFile = pkgs.writeText "config.ini" (lib.strings.concatStrings (
25
+
[ globalSection ] ++ (lib.lists.forEach cfg.routes (section:
27
+
name = section.route;
28
+
params = builtins.removeAttrs section [ "route" ];
options.services.stargazer = {
···
127
-
type = routesFormat.type;
135
+
type = lib.types.listOf
136
+
(lib.types.submodule {
137
+
freeformType = with lib.types; attrsOf (nullOr
144
+
description = "INI atom (null, bool, int, float or string)";
146
+
options.route = lib.mkOption {
147
+
type = lib.types.str;
148
+
description = lib.mdDoc "Route section name";
description = lib.mdDoc ''
Routes that Stargazer should server.
132
-
[Refer to upstream docs](https://git.sr.ht/~zethra/stargazer/tree/main/item/doc/stargazer.ini.5.txt)
155
+
Expressed as a list of attribute sets. Each set must have a key `route`
156
+
that becomes the section name for that route in the stargazer ini cofig.
157
+
The remaining keys and vaules become the parameters for that route.
159
+
[Refer to upstream docs for other params](https://git.sr.ht/~zethra/stargazer/tree/main/item/doc/stargazer.ini.5.txt)
134
-
example = literalExpression ''
137
-
root = "/srv/gemini/example.com";
139
-
"example.com:/man" = {
161
+
example = lib.literalExpression ''
164
+
route = "example.com";
165
+
root = "/srv/gemini/example.com"
168
+
route = "example.com:/man";
143
-
"other.org~(.*)" = {
173
+
route = "other.org~(.*)";
redirect = "gemini://example.com";