···
cfg = config.services.spacecookie;
7
-
configFile = pkgs.writeText "spacecookie.json" (lib.generators.toJSON {} {
8
-
inherit (cfg) hostname port root;
8
+
spacecookieConfig = {
12
+
format = pkgs.formats.json {};
14
+
configFile = format.generate "spacecookie.json" spacecookieConfig;
18
+
(mkRenamedOptionModule [ "services" "spacecookie" "root" ] [ "services" "spacecookie" "settings" "root" ])
19
+
(mkRenamedOptionModule [ "services" "spacecookie" "hostname" ] [ "services" "spacecookie" "settings" "hostname" ])
···
30
-
hostname = mkOption {
32
-
default = "localhost";
34
-
The hostname the service is reachable via. Clients
35
-
will use this hostname for further requests after
36
-
loading the initial gopher menu.
openFirewall = mkOption {
···
58
-
default = "/srv/gopher";
60
-
The root directory spacecookie serves via gopher.
···
<link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd.socket.html">systemd.socket(5)</link>.
66
+
settings = mkOption {
67
+
type = types.submodule {
68
+
freeformType = format.type;
70
+
options.hostname = mkOption {
72
+
default = "localhost";
74
+
The hostname the service is reachable via. Clients
75
+
will use this hostname for further requests after
76
+
loading the initial gopher menu.
80
+
options.root = mkOption {
82
+
default = "/srv/gopher";
84
+
The directory spacecookie should serve via gopher.
85
+
Files in there need to be world-readable since
86
+
the spacecookie service file sets
87
+
<literal>DynamicUser=true</literal>.
93
+
Settings for spacecookie. The settings set here are
94
+
directly translated to the spacecookie JSON config
96
+
<link xlink:href="https://github.com/sternenseemann/spacecookie/#configuration">spacecookie documentation</link>
97
+
for explanations of all options.
config = mkIf cfg.enable {
106
+
assertion = !(cfg.settings ? user);
108
+
spacecookie is started as a normal user, so the setuid
109
+
feature doesn't work. If you want to run spacecookie as
110
+
a specific user, set:
111
+
systemd.services.spacecookie.serviceConfig = {
112
+
DynamicUser = false;
114
+
Group = "yourgroup";
119
+
assertion = !(cfg.settings ? port);
121
+
The NixOS spacecookie module uses socket activation,
122
+
so the port option has no effect. Use the port option
123
+
in services.spacecookie instead.
systemd.sockets.spacecookie = {
description = "Socket for the Spacecookie Gopher Server";