4040 in join config.networking.hostName config.networking.domain;
4141in {
4242 networking = {
43- hostName = "myhostname";
44- domain = "example.org";
43+ < link linkend = " opt-networking. hostName" >hostName</ link > = "myhostname";
44+ < link linkend = " opt-networking. domain" >domain</ link > = "example.org";
4545 };
46- networking.firewall.allowedTCPPorts = [ 80 443 ];
46+ <link linkend =" opt-networking.firewall.allowedTCPPorts" >networking.firewall.allowedTCPPorts</link > = [ 80 443 ];
47+
48+ <link linkend =" opt-services.postgresql.enable" >services.postgresql.enable</link > = true;
49+ <link linkend =" opt-services.postgresql.initialScript" >services.postgresql.initialScript</link > = ''
50+ CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
51+ CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
52+ TEMPLATE template0
53+ LC_COLLATE = "C"
54+ LC_CTYPE = "C";
55+ '';
4756
4857 services.nginx = {
49- enable = true;
58+ < link linkend = " opt-services.nginx. enable" >enable</ link > = true;
5059 # only recommendedProxySettings and recommendedGzipSettings are strictly required,
5160 # but the rest make sense as well
52- recommendedTlsSettings = true;
53- recommendedOptimisation = true;
54- recommendedGzipSettings = true;
55- recommendedProxySettings = true;
61+ < link linkend = " opt-services.nginx. recommendedTlsSettings" >recommendedTlsSettings</ link > = true;
62+ < link linkend = " opt-services.nginx. recommendedOptimisation" >recommendedOptimisation</ link > = true;
63+ < link linkend = " opt-services.nginx. recommendedGzipSettings" >recommendedGzipSettings</ link > = true;
64+ < link linkend = " opt-services.nginx. recommendedProxySettings" >recommendedProxySettings</ link > = true;
5665
57- virtualHosts = {
66+ < link linkend = " opt-services.nginx. virtualHosts" >virtualHosts</ link > = {
5867 # This host section can be placed on a different host than the rest,
5968 # i.e. to delegate from the host being accessible as ${config.networking.domain}
6069 # to another host actually running the Matrix homeserver.
6170 "${config.networking.domain}" = {
62- locations." = /.well-known/matrix/server".extraConfig =
71+ < link linkend = " opt-services.nginx.virtualHosts._name_. locations._name_.extraConfig " >locations." = /.well-known/matrix/server".extraConfig</ link > =
6372 let
6473 # use 443 instead of the default 8448 port to unite
6574 # the client-server and server-server port for simplicity
6877 add_header Content-Type application/json;
6978 return 200 '${builtins.toJSON server}';
7079 '';
71- locations." = /.well-known/matrix/client".extraConfig =
80+ < link linkend = " opt-services.nginx.virtualHosts._name_. locations._name_.extraConfig " >locations." = /.well-known/matrix/client".extraConfig</ link > =
7281 let
7382 client = {
7483 "m.homeserver" = { "base_url" = "https://${fqdn}"; };
8493
8594 # Reverse proxy for Matrix client-server and server-server communication
8695 ${fqdn} = {
87- enableACME = true;
88- forceSSL = true;
96+ < link linkend = " opt-services.nginx.virtualHosts._name_. enableACME" >enableACME</ link > = true;
97+ < link linkend = " opt-services.nginx.virtualHosts._name_. forceSSL" >forceSSL</ link > = true;
8998
9099 # Or do a redirect instead of the 404, or whatever is appropriate for you.
91100 # But do not put a Matrix Web client here! See the Riot Web section below.
92- locations." /".extraConfig = ''
101+ < link linkend = " opt-services.nginx.virtualHosts._name_. locations._name_.extraConfig " >locations." /".extraConfig</ link > = ''
93102 return 404;
94103 '';
95104
96105 # forward all Matrix API calls to the synapse Matrix homeserver
97106 locations."/_matrix" = {
98- proxyPass = "http://[::1]:8008"; # without a trailing /
107+ < link linkend = " opt-services.nginx.virtualHosts._name_.locations._name_. proxyPass" >proxyPass</ link > = "http://[::1]:8008"; # without a trailing /
99108 };
100109 };
101110 };
102111 };
103112 services.matrix-synapse = {
104- enable = true;
105- server_name = config.networking.domain;
106- listeners = [
113+ < link linkend = " opt-services.matrix-synapse. enable" >enable</ link > = true;
114+ < link linkend = " opt-services.matrix-synapse. server_name" >server_name</ link > = config.networking.domain;
115+ < link linkend = " opt-services.matrix-synapse. listeners" >listeners</ link > = [
107116 {
108- port = 8008;
109- bind_address = "::1";
110- type = "http";
111- tls = false;
112- x_forwarded = true;
113- resources = [
114- { names = [ "client" "federation" ]; compress = false; }
117+ <link linkend =" opt-services.matrix-synapse.listeners._.port" >port</link > = 8008;
118+ <link linkend =" opt-services.matrix-synapse.listeners._.bind_address" >bind_address</link > = "::1";
119+ <link linkend =" opt-services.matrix-synapse.listeners._.type" >type</link > = "http";
120+ <link linkend =" opt-services.matrix-synapse.listeners._.tls" >tls</link > = false;
121+ <link linkend =" opt-services.matrix-synapse.listeners._.x_forwarded" >x_forwarded</link > = true;
122+ <link linkend =" opt-services.matrix-synapse.listeners._.resources" >resources</link > = [
123+ {
124+ <link linkend =" opt-services.matrix-synapse.listeners._.resources._.names" >names</link > = [ "client" "federation" ];
125+ <link linkend =" opt-services.matrix-synapse.listeners._.resources._.compress" >compress</link > = false;
126+ }
115127 ];
116128 }
117129 ];
@@ -135,10 +147,10 @@ in {
135147
136148 <para >
137149 If you want to run a server with public registration by anybody, you can
138- then enable <option > services.matrix-synapse.enable_registration =
139- true;</option >. Otherwise, or you can generate a registration secret with
150+ then enable <literal >< link linkend = " opt- services.matrix-synapse.enable_registration" >services.matrix-synapse.enable_registration</ link > =
151+ true;</literal >. Otherwise, or you can generate a registration secret with
140152 <command >pwgen -s 64 1</command > and set it with
141- <option >services.matrix-synapse.registration_shared_secret</option >. To
153+ <option >< link linkend = " opt- services.matrix-synapse.registration_shared_secret" >services.matrix-synapse.registration_shared_secret</ link > </option >. To
142154 create a new user or admin, run the following after you have set the secret
143155 and have rebuilt NixOS:
144156<screen >
@@ -154,8 +166,8 @@ Success!
154166 <literal >@your-username:example.org</literal >. Note that the registration
155167 secret ends up in the nix store and therefore is world-readable by any user
156168 on your machine, so it makes sense to only temporarily activate the
157- <option >registration_shared_secret</option > option until a better solution
158- for NixOS is in place.
169+ <link linkend = " opt-services.matrix-synapse.registration_shared_secret " >registration_shared_secret</link >
170+ option until a better solution for NixOS is in place.
159171 </para >
160172 </section >
161173 <section xml : id =" module-services-matrix-riot-web" >
@@ -177,15 +189,24 @@ Success!
177189 Matrix Now!</link > for a list of existing clients and their supported
178190 featureset.
179191<programlisting >
180- services.nginx.virtualHosts."riot.${fqdn}" = {
181- enableACME = true;
182- forceSSL = true;
183- serverAliases = [
184- "riot.${config.networking.domain}"
185- ];
192+ {
193+ services.nginx.virtualHosts."riot.${fqdn}" = {
194+ <link linkend =" opt-services.nginx.virtualHosts._name_.enableACME" >enableACME</link > = true;
195+ <link linkend =" opt-services.nginx.virtualHosts._name_.forceSSL" >forceSSL</link > = true;
196+ <link linkend =" opt-services.nginx.virtualHosts._name_.serverAliases" >serverAliases</link > = [
197+ "riot.${config.networking.domain}"
198+ ];
186199
187- root = pkgs.riot-web;
188- };
200+ <link linkend =" opt-services.nginx.virtualHosts._name_.root" >root</link > = pkgs.riot-web.override {
201+ conf = {
202+ default_server_config."m.homeserver" = {
203+ "base_url" = "${config.networking.domain}";
204+ "server_name" = "${fqdn}";
205+ };
206+ };
207+ };
208+ };
209+ }
189210</programlisting >
190211 </para >
191212
0 commit comments