···11+# Nextcloud {#module-services-nextcloud}
22+33+[Nextcloud](https://nextcloud.com/) is an open-source,
44+self-hostable cloud platform. The server setup can be automated using
55+[services.nextcloud](#opt-services.nextcloud.enable). A
66+desktop client is packaged at `pkgs.nextcloud-client`.
77+88+The current default by NixOS is `nextcloud25` which is also the latest
99+major version available.
1010+1111+## Basic usage {#module-services-nextcloud-basic-usage}
1212+1313+Nextcloud is a PHP-based application which requires an HTTP server
1414+([`services.nextcloud`](#opt-services.nextcloud.enable)
1515+optionally supports
1616+[`services.nginx`](#opt-services.nginx.enable))
1717+and a database (it's recommended to use
1818+[`services.postgresql`](#opt-services.postgresql.enable)).
1919+2020+A very basic configuration may look like this:
2121+```
2222+{ pkgs, ... }:
2323+{
2424+ services.nextcloud = {
2525+ enable = true;
2626+ hostName = "nextcloud.tld";
2727+ config = {
2828+ dbtype = "pgsql";
2929+ dbuser = "nextcloud";
3030+ dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself
3131+ dbname = "nextcloud";
3232+ adminpassFile = "/path/to/admin-pass-file";
3333+ adminuser = "root";
3434+ };
3535+ };
3636+3737+ services.postgresql = {
3838+ enable = true;
3939+ ensureDatabases = [ "nextcloud" ];
4040+ ensureUsers = [
4141+ { name = "nextcloud";
4242+ ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
4343+ }
4444+ ];
4545+ };
4646+4747+ # ensure that postgres is running *before* running the setup
4848+ systemd.services."nextcloud-setup" = {
4949+ requires = ["postgresql.service"];
5050+ after = ["postgresql.service"];
5151+ };
5252+5353+ networking.firewall.allowedTCPPorts = [ 80 443 ];
5454+}
5555+```
5656+5757+The `hostName` option is used internally to configure an HTTP
5858+server using [`PHP-FPM`](https://php-fpm.org/)
5959+and `nginx`. The `config` attribute set is
6060+used by the imperative installer and all values are written to an additional file
6161+to ensure that changes can be applied by changing the module's options.
6262+6363+In case the application serves multiple domains (those are checked with
6464+[`$_SERVER['HTTP_HOST']`](http://php.net/manual/en/reserved.variables.server.php))
6565+it's needed to add them to
6666+[`services.nextcloud.config.extraTrustedDomains`](#opt-services.nextcloud.config.extraTrustedDomains).
6767+6868+Auto updates for Nextcloud apps can be enabled using
6969+[`services.nextcloud.autoUpdateApps`](#opt-services.nextcloud.autoUpdateApps.enable).
7070+7171+## Common problems {#module-services-nextcloud-pitfalls-during-upgrade}
7272+7373+ - **General notes.**
7474+ Unfortunately Nextcloud appears to be very stateful when it comes to
7575+ managing its own configuration. The config file lives in the home directory
7676+ of the `nextcloud` user (by default
7777+ `/var/lib/nextcloud/config/config.php`) and is also used to
7878+ track several states of the application (e.g., whether installed or not).
7979+8080+ All configuration parameters are also stored in
8181+ {file}`/var/lib/nextcloud/config/override.config.php` which is generated by
8282+ the module and linked from the store to ensure that all values from
8383+ {file}`config.php` can be modified by the module.
8484+ However {file}`config.php` manages the application's state and shouldn't be
8585+ touched manually because of that.
8686+8787+ ::: {.warning}
8888+ Don't delete {file}`config.php`! This file
8989+ tracks the application's state and a deletion can cause unwanted
9090+ side-effects!
9191+ :::
9292+9393+ ::: {.warning}
9494+ Don't rerun `nextcloud-occ maintenance:install`!
9595+ This command tries to install the application
9696+ and can cause unwanted side-effects!
9797+ :::
9898+ - **Multiple version upgrades.**
9999+ Nextcloud doesn't allow to move more than one major-version forward. E.g., if you're on
100100+ `v16`, you cannot upgrade to `v18`, you need to upgrade to
101101+ `v17` first. This is ensured automatically as long as the
102102+ [stateVersion](#opt-system.stateVersion) is declared properly. In that case
103103+ the oldest version available (one major behind the one from the previous NixOS
104104+ release) will be selected by default and the module will generate a warning that reminds
105105+ the user to upgrade to latest Nextcloud *after* that deploy.
106106+ - **`Error: Command "upgrade" is not defined.`**
107107+ This error usually occurs if the initial installation
108108+ ({command}`nextcloud-occ maintenance:install`) has failed. After that, the application
109109+ is not installed, but the upgrade is attempted to be executed. Further context can
110110+ be found in [NixOS/nixpkgs#111175](https://github.com/NixOS/nixpkgs/issues/111175).
111111+112112+ First of all, it makes sense to find out what went wrong by looking at the logs
113113+ of the installation via {command}`journalctl -u nextcloud-setup` and try to fix
114114+ the underlying issue.
115115+116116+ - If this occurs on an *existing* setup, this is most likely because
117117+ the maintenance mode is active. It can be deactivated by running
118118+ {command}`nextcloud-occ maintenance:mode --off`. It's advisable though to
119119+ check the logs first on why the maintenance mode was activated.
120120+ - ::: {.warning}
121121+ Only perform the following measures on
122122+ *freshly installed instances!*
123123+ :::
124124+125125+ A re-run of the installer can be forced by *deleting*
126126+ {file}`/var/lib/nextcloud/config/config.php`. This is the only time
127127+ advisable because the fresh install doesn't have any state that can be lost.
128128+ In case that doesn't help, an entire re-creation can be forced via
129129+ {command}`rm -rf ~nextcloud/`.
130130+131131+ - **Server-side encryption.**
132132+ Nextcloud supports [server-side encryption (SSE)](https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/encryption_configuration.html).
133133+ This is not an end-to-end encryption, but can be used to encrypt files that will be persisted
134134+ to external storage such as S3. Please note that this won't work anymore when using OpenSSL 3
135135+ for PHP's openssl extension because this is implemented using the legacy cipher RC4.
136136+ If [](#opt-system.stateVersion) is *above* `22.05`,
137137+ this is disabled by default. To turn it on again and for further information please refer to
138138+ [](#opt-services.nextcloud.enableBrokenCiphersForSSE).
139139+140140+## Using an alternative webserver as reverse-proxy (e.g. `httpd`) {#module-services-nextcloud-httpd}
141141+142142+By default, `nginx` is used as reverse-proxy for `nextcloud`.
143143+However, it's possible to use e.g. `httpd` by explicitly disabling
144144+`nginx` using [](#opt-services.nginx.enable) and fixing the
145145+settings `listen.owner` & `listen.group` in the
146146+[corresponding `phpfpm` pool](#opt-services.phpfpm.pools).
147147+148148+An exemplary configuration may look like this:
149149+```
150150+{ config, lib, pkgs, ... }: {
151151+ services.nginx.enable = false;
152152+ services.nextcloud = {
153153+ enable = true;
154154+ hostName = "localhost";
155155+156156+ /* further, required options */
157157+ };
158158+ services.phpfpm.pools.nextcloud.settings = {
159159+ "listen.owner" = config.services.httpd.user;
160160+ "listen.group" = config.services.httpd.group;
161161+ };
162162+ services.httpd = {
163163+ enable = true;
164164+ adminAddr = "webmaster@localhost";
165165+ extraModules = [ "proxy_fcgi" ];
166166+ virtualHosts."localhost" = {
167167+ documentRoot = config.services.nextcloud.package;
168168+ extraConfig = ''
169169+ <Directory "${config.services.nextcloud.package}">
170170+ <FilesMatch "\.php$">
171171+ <If "-f %{REQUEST_FILENAME}">
172172+ SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud.socket}|fcgi://localhost/"
173173+ </If>
174174+ </FilesMatch>
175175+ <IfModule mod_rewrite.c>
176176+ RewriteEngine On
177177+ RewriteBase /
178178+ RewriteRule ^index\.php$ - [L]
179179+ RewriteCond %{REQUEST_FILENAME} !-f
180180+ RewriteCond %{REQUEST_FILENAME} !-d
181181+ RewriteRule . /index.php [L]
182182+ </IfModule>
183183+ DirectoryIndex index.php
184184+ Require all granted
185185+ Options +FollowSymLinks
186186+ </Directory>
187187+ '';
188188+ };
189189+ };
190190+}
191191+```
192192+193193+## Installing Apps and PHP extensions {#installing-apps-php-extensions-nextcloud}
194194+195195+Nextcloud apps are installed statefully through the web interface.
196196+Some apps may require extra PHP extensions to be installed.
197197+This can be configured with the [](#opt-services.nextcloud.phpExtraExtensions) setting.
198198+199199+Alternatively, extra apps can also be declared with the [](#opt-services.nextcloud.extraApps) setting.
200200+When using this setting, apps can no longer be managed statefully because this can lead to Nextcloud updating apps
201201+that are managed by Nix. If you want automatic updates it is recommended that you use web interface to install apps.
202202+203203+## Maintainer information {#module-services-nextcloud-maintainer-info}
204204+205205+As stated in the previous paragraph, we must provide a clean upgrade-path for Nextcloud
206206+since it cannot move more than one major version forward on a single upgrade. This chapter
207207+adds some notes how Nextcloud updates should be rolled out in the future.
208208+209209+While minor and patch-level updates are no problem and can be done directly in the
210210+package-expression (and should be backported to supported stable branches after that),
211211+major-releases should be added in a new attribute (e.g. Nextcloud `v19.0.0`
212212+should be available in `nixpkgs` as `pkgs.nextcloud19`).
213213+To provide simple upgrade paths it's generally useful to backport those as well to stable
214214+branches. As long as the package-default isn't altered, this won't break existing setups.
215215+After that, the versioning-warning in the `nextcloud`-module should be
216216+updated to make sure that the
217217+[package](#opt-services.nextcloud.package)-option selects the latest version
218218+on fresh setups.
219219+220220+If major-releases will be abandoned by upstream, we should check first if those are needed
221221+in NixOS for a safe upgrade-path before removing those. In that case we should keep those
222222+packages, but mark them as insecure in an expression like this (in
223223+`<nixpkgs/pkgs/servers/nextcloud/default.nix>`):
224224+```
225225+/* ... */
226226+{
227227+ nextcloud17 = generic {
228228+ version = "17.0.x";
229229+ sha256 = "0000000000000000000000000000000000000000000000000000";
230230+ eol = true;
231231+ };
232232+}
233233+```
234234+235235+Ideally we should make sure that it's possible to jump two NixOS versions forward:
236236+i.e. the warnings and the logic in the module should guard a user to upgrade from a
237237+Nextcloud on e.g. 19.09 to a Nextcloud on 20.09.
+2
nixos/modules/services/web-apps/nextcloud.nix
···11461146 }
11471147 ]);
1148114811491149+ # Don't edit the docbook xml directly, edit the md and generate it:
11501150+ # `pandoc nextcloud.md -t docbook --top-level-division=chapter --extract-media=media -f markdown-smart --lua-filter ../../../../doc/build-aux/pandoc-filters/myst-reader/roles.lua --lua-filter ../../../../doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua > nextcloud.xml`
11491151 meta.doc = ./nextcloud.xml;
11501152}
+261-241
nixos/modules/services/web-apps/nextcloud.xml
···11-<chapter xmlns="http://docbook.org/ns/docbook"
22- xmlns:xlink="http://www.w3.org/1999/xlink"
33- xmlns:xi="http://www.w3.org/2001/XInclude"
44- version="5.0"
55- xml:id="module-services-nextcloud">
66- <title>Nextcloud</title>
77- <para>
88- <link xlink:href="https://nextcloud.com/">Nextcloud</link> is an open-source,
99- self-hostable cloud platform. The server setup can be automated using
1010- <link linkend="opt-services.nextcloud.enable">services.nextcloud</link>. A
1111- desktop client is packaged at <literal>pkgs.nextcloud-client</literal>.
1212- </para>
1313- <para>
1414- The current default by NixOS is <literal>nextcloud25</literal> which is also the latest
1515- major version available.
1616- </para>
1717- <section xml:id="module-services-nextcloud-basic-usage">
1818- <title>Basic usage</title>
1919-11+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="module-services-nextcloud">
22+ <title>Nextcloud</title>
203 <para>
2121- Nextcloud is a PHP-based application which requires an HTTP server
2222- (<link linkend="opt-services.nextcloud.enable"><literal>services.nextcloud</literal></link>
2323- optionally supports
2424- <link linkend="opt-services.nginx.enable"><literal>services.nginx</literal></link>)
2525- and a database (it's recommended to use
2626- <link linkend="opt-services.postgresql.enable"><literal>services.postgresql</literal></link>).
44+ <link xlink:href="https://nextcloud.com/">Nextcloud</link> is an
55+ open-source, self-hostable cloud platform. The server setup can be
66+ automated using
77+ <link linkend="opt-services.nextcloud.enable">services.nextcloud</link>.
88+ A desktop client is packaged at
99+ <literal>pkgs.nextcloud-client</literal>.
2710 </para>
2828-2911 <para>
3030- A very basic configuration may look like this:
3131-<programlisting>
1212+ The current default by NixOS is <literal>nextcloud25</literal> which
1313+ is also the latest major version available.
1414+ </para>
1515+ <section xml:id="module-services-nextcloud-basic-usage">
1616+ <title>Basic usage</title>
1717+ <para>
1818+ Nextcloud is a PHP-based application which requires an HTTP server
1919+ (<link linkend="opt-services.nextcloud.enable"><literal>services.nextcloud</literal></link>
2020+ optionally supports
2121+ <link linkend="opt-services.nginx.enable"><literal>services.nginx</literal></link>)
2222+ and a database (it's recommended to use
2323+ <link linkend="opt-services.postgresql.enable"><literal>services.postgresql</literal></link>).
2424+ </para>
2525+ <para>
2626+ A very basic configuration may look like this:
2727+ </para>
2828+ <programlisting>
3229{ pkgs, ... }:
3330{
3431 services.nextcloud = {
3532 enable = true;
3636- hostName = "nextcloud.tld";
3333+ hostName = "nextcloud.tld";
3734 config = {
3838- dbtype = "pgsql";
3939- dbuser = "nextcloud";
4040- dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself
4141- dbname = "nextcloud";
4242- adminpassFile = "/path/to/admin-pass-file";
4343- adminuser = "root";
3535+ dbtype = "pgsql";
3636+ dbuser = "nextcloud";
3737+ dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself
3838+ dbname = "nextcloud";
3939+ adminpassFile = "/path/to/admin-pass-file";
4040+ adminuser = "root";
4441 };
4542 };
46434744 services.postgresql = {
4845 enable = true;
4949- ensureDatabases = [ "nextcloud" ];
4646+ ensureDatabases = [ "nextcloud" ];
5047 ensureUsers = [
5151- { name = "nextcloud";
5252- ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
4848+ { name = "nextcloud";
4949+ ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
5350 }
5451 ];
5552 };
56535754 # ensure that postgres is running *before* running the setup
5858- systemd.services."nextcloud-setup" = {
5959- requires = ["postgresql.service"];
6060- after = ["postgresql.service"];
5555+ systemd.services."nextcloud-setup" = {
5656+ requires = ["postgresql.service"];
5757+ after = ["postgresql.service"];
6158 };
62596360 networking.firewall.allowedTCPPorts = [ 80 443 ];
6461}
6562</programlisting>
6666- </para>
6767-6868- <para>
6969- The <literal>hostName</literal> option is used internally to configure an HTTP
7070- server using <link xlink:href="https://php-fpm.org/"><literal>PHP-FPM</literal></link>
7171- and <literal>nginx</literal>. The <literal>config</literal> attribute set is
7272- used by the imperative installer and all values are written to an additional file
7373- to ensure that changes can be applied by changing the module's options.
7474- </para>
7575-7676- <para>
7777- In case the application serves multiple domains (those are checked with
7878- <link xlink:href="http://php.net/manual/en/reserved.variables.server.php"><literal>$_SERVER['HTTP_HOST']</literal></link>)
7979- it's needed to add them to
8080- <link linkend="opt-services.nextcloud.config.extraTrustedDomains"><literal>services.nextcloud.config.extraTrustedDomains</literal></link>.
8181- </para>
8282-8383- <para>
8484- Auto updates for Nextcloud apps can be enabled using
8585- <link linkend="opt-services.nextcloud.autoUpdateApps.enable"><literal>services.nextcloud.autoUpdateApps</literal></link>.
8686-</para>
8787-8888- </section>
8989-9090- <section xml:id="module-services-nextcloud-pitfalls-during-upgrade">
9191- <title>Common problems</title>
9292- <itemizedlist>
9393- <listitem>
9494- <formalpara>
9595- <title>General notes</title>
9696- <para>
9797- Unfortunately Nextcloud appears to be very stateful when it comes to
9898- managing its own configuration. The config file lives in the home directory
9999- of the <literal>nextcloud</literal> user (by default
100100- <literal>/var/lib/nextcloud/config/config.php</literal>) and is also used to
101101- track several states of the application (e.g., whether installed or not).
102102- </para>
103103- </formalpara>
6363+ <para>
6464+ The <literal>hostName</literal> option is used internally to
6565+ configure an HTTP server using
6666+ <link xlink:href="https://php-fpm.org/"><literal>PHP-FPM</literal></link>
6767+ and <literal>nginx</literal>. The <literal>config</literal>
6868+ attribute set is used by the imperative installer and all values
6969+ are written to an additional file to ensure that changes can be
7070+ applied by changing the module's options.
7171+ </para>
10472 <para>
105105- All configuration parameters are also stored in
106106- <filename>/var/lib/nextcloud/config/override.config.php</filename> which is generated by
107107- the module and linked from the store to ensure that all values from
108108- <filename>config.php</filename> can be modified by the module.
109109- However <filename>config.php</filename> manages the application's state and shouldn't be
110110- touched manually because of that.
7373+ In case the application serves multiple domains (those are checked
7474+ with
7575+ <link xlink:href="http://php.net/manual/en/reserved.variables.server.php"><literal>$_SERVER['HTTP_HOST']</literal></link>)
7676+ it's needed to add them to
7777+ <link linkend="opt-services.nextcloud.config.extraTrustedDomains"><literal>services.nextcloud.config.extraTrustedDomains</literal></link>.
11178 </para>
112112- <warning>
113113- <para>Don't delete <filename>config.php</filename>! This file
114114- tracks the application's state and a deletion can cause unwanted
115115- side-effects!</para>
116116- </warning>
117117-118118- <warning>
119119- <para>Don't rerun <literal>nextcloud-occ
120120- maintenance:install</literal>! This command tries to install the application
121121- and can cause unwanted side-effects!</para>
122122- </warning>
123123- </listitem>
124124- <listitem>
125125- <formalpara>
126126- <title>Multiple version upgrades</title>
127127- <para>
128128- Nextcloud doesn't allow to move more than one major-version forward. E.g., if you're on
129129- <literal>v16</literal>, you cannot upgrade to <literal>v18</literal>, you need to upgrade to
130130- <literal>v17</literal> first. This is ensured automatically as long as the
131131- <link linkend="opt-system.stateVersion">stateVersion</link> is declared properly. In that case
132132- the oldest version available (one major behind the one from the previous NixOS
133133- release) will be selected by default and the module will generate a warning that reminds
134134- the user to upgrade to latest Nextcloud <emphasis>after</emphasis> that deploy.
135135- </para>
136136- </formalpara>
137137- </listitem>
138138- <listitem>
139139- <formalpara>
140140- <title><literal>Error: Command "upgrade" is not defined.</literal></title>
141141- <para>
142142- This error usually occurs if the initial installation
143143- (<command>nextcloud-occ maintenance:install</command>) has failed. After that, the application
144144- is not installed, but the upgrade is attempted to be executed. Further context can
145145- be found in <link xlink:href="https://github.com/NixOS/nixpkgs/issues/111175">NixOS/nixpkgs#111175</link>.
146146- </para>
147147- </formalpara>
14879 <para>
149149- First of all, it makes sense to find out what went wrong by looking at the logs
150150- of the installation via <command>journalctl -u nextcloud-setup</command> and try to fix
151151- the underlying issue.
8080+ Auto updates for Nextcloud apps can be enabled using
8181+ <link linkend="opt-services.nextcloud.autoUpdateApps.enable"><literal>services.nextcloud.autoUpdateApps</literal></link>.
15282 </para>
8383+ </section>
8484+ <section xml:id="module-services-nextcloud-pitfalls-during-upgrade">
8585+ <title>Common problems</title>
15386 <itemizedlist>
154154- <listitem>
155155- <para>
156156- If this occurs on an <emphasis>existing</emphasis> setup, this is most likely because
157157- the maintenance mode is active. It can be deactivated by running
158158- <command>nextcloud-occ maintenance:mode --off</command>. It's advisable though to
159159- check the logs first on why the maintenance mode was activated.
160160- </para>
161161- </listitem>
162162- <listitem>
163163- <warning><para>Only perform the following measures on
164164- <emphasis>freshly installed instances!</emphasis></para></warning>
165165- <para>
166166- A re-run of the installer can be forced by <emphasis>deleting</emphasis>
167167- <filename>/var/lib/nextcloud/config/config.php</filename>. This is the only time
168168- advisable because the fresh install doesn't have any state that can be lost.
169169- In case that doesn't help, an entire re-creation can be forced via
170170- <command>rm -rf ~nextcloud/</command>.
171171- </para>
172172- </listitem>
8787+ <listitem>
8888+ <para>
8989+ <emphasis role="strong">General notes.</emphasis>
9090+ Unfortunately Nextcloud appears to be very stateful when it
9191+ comes to managing its own configuration. The config file lives
9292+ in the home directory of the <literal>nextcloud</literal> user
9393+ (by default
9494+ <literal>/var/lib/nextcloud/config/config.php</literal>) and
9595+ is also used to track several states of the application (e.g.,
9696+ whether installed or not).
9797+ </para>
9898+ <para>
9999+ All configuration parameters are also stored in
100100+ <filename>/var/lib/nextcloud/config/override.config.php</filename>
101101+ which is generated by the module and linked from the store to
102102+ ensure that all values from <filename>config.php</filename>
103103+ can be modified by the module. However
104104+ <filename>config.php</filename> manages the application's
105105+ state and shouldn't be touched manually because of that.
106106+ </para>
107107+ <warning>
108108+ <para>
109109+ Don't delete <filename>config.php</filename>! This file
110110+ tracks the application's state and a deletion can cause
111111+ unwanted side-effects!
112112+ </para>
113113+ </warning>
114114+ <warning>
115115+ <para>
116116+ Don't rerun
117117+ <literal>nextcloud-occ maintenance:install</literal>! This
118118+ command tries to install the application and can cause
119119+ unwanted side-effects!
120120+ </para>
121121+ </warning>
122122+ </listitem>
123123+ <listitem>
124124+ <para>
125125+ <emphasis role="strong">Multiple version upgrades.</emphasis>
126126+ Nextcloud doesn't allow to move more than one major-version
127127+ forward. E.g., if you're on <literal>v16</literal>, you cannot
128128+ upgrade to <literal>v18</literal>, you need to upgrade to
129129+ <literal>v17</literal> first. This is ensured automatically as
130130+ long as the
131131+ <link linkend="opt-system.stateVersion">stateVersion</link> is
132132+ declared properly. In that case the oldest version available
133133+ (one major behind the one from the previous NixOS release)
134134+ will be selected by default and the module will generate a
135135+ warning that reminds the user to upgrade to latest Nextcloud
136136+ <emphasis>after</emphasis> that deploy.
137137+ </para>
138138+ </listitem>
139139+ <listitem>
140140+ <para>
141141+ <emphasis role="strong"><literal>Error: Command "upgrade" is not defined.</literal></emphasis>
142142+ This error usually occurs if the initial installation
143143+ (<command>nextcloud-occ maintenance:install</command>) has
144144+ failed. After that, the application is not installed, but the
145145+ upgrade is attempted to be executed. Further context can be
146146+ found in
147147+ <link xlink:href="https://github.com/NixOS/nixpkgs/issues/111175">NixOS/nixpkgs#111175</link>.
148148+ </para>
149149+ <para>
150150+ First of all, it makes sense to find out what went wrong by
151151+ looking at the logs of the installation via
152152+ <command>journalctl -u nextcloud-setup</command> and try to
153153+ fix the underlying issue.
154154+ </para>
155155+ <itemizedlist>
156156+ <listitem>
157157+ <para>
158158+ If this occurs on an <emphasis>existing</emphasis> setup,
159159+ this is most likely because the maintenance mode is
160160+ active. It can be deactivated by running
161161+ <command>nextcloud-occ maintenance:mode --off</command>.
162162+ It's advisable though to check the logs first on why the
163163+ maintenance mode was activated.
164164+ </para>
165165+ </listitem>
166166+ <listitem>
167167+ <warning>
168168+ <para>
169169+ Only perform the following measures on <emphasis>freshly
170170+ installed instances!</emphasis>
171171+ </para>
172172+ </warning>
173173+ <para>
174174+ A re-run of the installer can be forced by
175175+ <emphasis>deleting</emphasis>
176176+ <filename>/var/lib/nextcloud/config/config.php</filename>.
177177+ This is the only time advisable because the fresh install
178178+ doesn't have any state that can be lost. In case that
179179+ doesn't help, an entire re-creation can be forced via
180180+ <command>rm -rf ~nextcloud/</command>.
181181+ </para>
182182+ </listitem>
183183+ </itemizedlist>
184184+ </listitem>
185185+ <listitem>
186186+ <para>
187187+ <emphasis role="strong">Server-side encryption.</emphasis>
188188+ Nextcloud supports
189189+ <link xlink:href="https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/encryption_configuration.html">server-side
190190+ encryption (SSE)</link>. This is not an end-to-end encryption,
191191+ but can be used to encrypt files that will be persisted to
192192+ external storage such as S3. Please note that this won't work
193193+ anymore when using OpenSSL 3 for PHP's openssl extension
194194+ because this is implemented using the legacy cipher RC4. If
195195+ <xref linkend="opt-system.stateVersion"></xref> is
196196+ <emphasis>above</emphasis> <literal>22.05</literal>, this is
197197+ disabled by default. To turn it on again and for further
198198+ information please refer to
199199+ <xref linkend="opt-services.nextcloud.enableBrokenCiphersForSSE"></xref>.
200200+ </para>
201201+ </listitem>
173202 </itemizedlist>
174174- </listitem>
175175- <listitem>
176176- <formalpara>
177177- <title>Server-side encryption</title>
178178- <para>
179179- Nextcloud supports <link xlink:href="https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/encryption_configuration.html">server-side encryption (SSE)</link>.
180180- This is not an end-to-end encryption, but can be used to encrypt files that will be persisted
181181- to external storage such as S3. Please note that this won't work anymore when using OpenSSL 3
182182- for PHP's openssl extension because this is implemented using the legacy cipher RC4.
183183- If <xref linkend="opt-system.stateVersion" /> is <emphasis>above</emphasis> <literal>22.05</literal>,
184184- this is disabled by default. To turn it on again and for further information please refer to
185185- <xref linkend="opt-services.nextcloud.enableBrokenCiphersForSSE" />.
186186- </para>
187187- </formalpara>
188188- </listitem>
189189- </itemizedlist>
190190- </section>
191191-192192- <section xml:id="module-services-nextcloud-httpd">
193193- <title>Using an alternative webserver as reverse-proxy (e.g. <literal>httpd</literal>)</title>
194194- <para>
195195- By default, <literal>nginx</literal> is used as reverse-proxy for <literal>nextcloud</literal>.
196196- However, it's possible to use e.g. <literal>httpd</literal> by explicitly disabling
197197- <literal>nginx</literal> using <xref linkend="opt-services.nginx.enable" /> and fixing the
198198- settings <literal>listen.owner</literal> & <literal>listen.group</literal> in the
199199- <link linkend="opt-services.phpfpm.pools">corresponding <literal>phpfpm</literal> pool</link>.
200200- </para>
201201- <para>
202202- An exemplary configuration may look like this:
203203-<programlisting>
203203+ </section>
204204+ <section xml:id="module-services-nextcloud-httpd">
205205+ <title>Using an alternative webserver as reverse-proxy (e.g.
206206+ <literal>httpd</literal>)</title>
207207+ <para>
208208+ By default, <literal>nginx</literal> is used as reverse-proxy for
209209+ <literal>nextcloud</literal>. However, it's possible to use e.g.
210210+ <literal>httpd</literal> by explicitly disabling
211211+ <literal>nginx</literal> using
212212+ <xref linkend="opt-services.nginx.enable"></xref> and fixing the
213213+ settings <literal>listen.owner</literal> &
214214+ <literal>listen.group</literal> in the
215215+ <link linkend="opt-services.phpfpm.pools">corresponding
216216+ <literal>phpfpm</literal> pool</link>.
217217+ </para>
218218+ <para>
219219+ An exemplary configuration may look like this:
220220+ </para>
221221+ <programlisting>
204222{ config, lib, pkgs, ... }: {
205223 services.nginx.enable = false;
206224 services.nextcloud = {
207225 enable = true;
208208- hostName = "localhost";
226226+ hostName = "localhost";
209227210228 /* further, required options */
211229 };
212230 services.phpfpm.pools.nextcloud.settings = {
213213- "listen.owner" = config.services.httpd.user;
214214- "listen.group" = config.services.httpd.group;
231231+ "listen.owner" = config.services.httpd.user;
232232+ "listen.group" = config.services.httpd.group;
215233 };
216234 services.httpd = {
217235 enable = true;
218218- adminAddr = "webmaster@localhost";
219219- extraModules = [ "proxy_fcgi" ];
220220- virtualHosts."localhost" = {
236236+ adminAddr = "webmaster@localhost";
237237+ extraModules = [ "proxy_fcgi" ];
238238+ virtualHosts."localhost" = {
221239 documentRoot = config.services.nextcloud.package;
222240 extraConfig = ''
223223- <Directory "${config.services.nextcloud.package}">
224224- <FilesMatch "\.php$">
225225- <If "-f %{REQUEST_FILENAME}">
226226- SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud.socket}|fcgi://localhost/"
241241+ <Directory "${config.services.nextcloud.package}">
242242+ <FilesMatch "\.php$">
243243+ <If "-f %{REQUEST_FILENAME}">
244244+ SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud.socket}|fcgi://localhost/"
227245 </If>
228246 </FilesMatch>
229247 <IfModule mod_rewrite.c>
···243261 };
244262}
245263</programlisting>
246246- </para>
247247- </section>
248248-249249- <section xml:id="installing-apps-php-extensions-nextcloud">
250250- <title>Installing Apps and PHP extensions</title>
251251-252252- <para>
253253- Nextcloud apps are installed statefully through the web interface.
254254-255255- Some apps may require extra PHP extensions to be installed.
256256- This can be configured with the <xref linkend="opt-services.nextcloud.phpExtraExtensions" /> setting.
257257- </para>
258258-259259- <para>
260260- Alternatively, extra apps can also be declared with the <xref linkend="opt-services.nextcloud.extraApps" /> setting.
261261- When using this setting, apps can no longer be managed statefully because this can lead to Nextcloud updating apps
262262- that are managed by Nix. If you want automatic updates it is recommended that you use web interface to install apps.
263263- </para>
264264- </section>
265265-266266- <section xml:id="module-services-nextcloud-maintainer-info">
267267- <title>Maintainer information</title>
268268-269269- <para>
270270- As stated in the previous paragraph, we must provide a clean upgrade-path for Nextcloud
271271- since it cannot move more than one major version forward on a single upgrade. This chapter
272272- adds some notes how Nextcloud updates should be rolled out in the future.
273273- </para>
274274-275275- <para>
276276- While minor and patch-level updates are no problem and can be done directly in the
277277- package-expression (and should be backported to supported stable branches after that),
278278- major-releases should be added in a new attribute (e.g. Nextcloud <literal>v19.0.0</literal>
279279- should be available in <literal>nixpkgs</literal> as <literal>pkgs.nextcloud19</literal>).
280280- To provide simple upgrade paths it's generally useful to backport those as well to stable
281281- branches. As long as the package-default isn't altered, this won't break existing setups.
282282- After that, the versioning-warning in the <literal>nextcloud</literal>-module should be
283283- updated to make sure that the
284284- <link linkend="opt-services.nextcloud.package">package</link>-option selects the latest version
285285- on fresh setups.
286286- </para>
287287-288288- <para>
289289- If major-releases will be abandoned by upstream, we should check first if those are needed
290290- in NixOS for a safe upgrade-path before removing those. In that case we should keep those
291291- packages, but mark them as insecure in an expression like this (in
292292- <literal><nixpkgs/pkgs/servers/nextcloud/default.nix></literal>):
293293-<programlisting>
264264+ </section>
265265+ <section xml:id="installing-apps-php-extensions-nextcloud">
266266+ <title>Installing Apps and PHP extensions</title>
267267+ <para>
268268+ Nextcloud apps are installed statefully through the web interface.
269269+ Some apps may require extra PHP extensions to be installed. This
270270+ can be configured with the
271271+ <xref linkend="opt-services.nextcloud.phpExtraExtensions"></xref>
272272+ setting.
273273+ </para>
274274+ <para>
275275+ Alternatively, extra apps can also be declared with the
276276+ <xref linkend="opt-services.nextcloud.extraApps"></xref> setting.
277277+ When using this setting, apps can no longer be managed statefully
278278+ because this can lead to Nextcloud updating apps that are managed
279279+ by Nix. If you want automatic updates it is recommended that you
280280+ use web interface to install apps.
281281+ </para>
282282+ </section>
283283+ <section xml:id="module-services-nextcloud-maintainer-info">
284284+ <title>Maintainer information</title>
285285+ <para>
286286+ As stated in the previous paragraph, we must provide a clean
287287+ upgrade-path for Nextcloud since it cannot move more than one
288288+ major version forward on a single upgrade. This chapter adds some
289289+ notes how Nextcloud updates should be rolled out in the future.
290290+ </para>
291291+ <para>
292292+ While minor and patch-level updates are no problem and can be done
293293+ directly in the package-expression (and should be backported to
294294+ supported stable branches after that), major-releases should be
295295+ added in a new attribute (e.g. Nextcloud
296296+ <literal>v19.0.0</literal> should be available in
297297+ <literal>nixpkgs</literal> as
298298+ <literal>pkgs.nextcloud19</literal>). To provide simple upgrade
299299+ paths it's generally useful to backport those as well to stable
300300+ branches. As long as the package-default isn't altered, this won't
301301+ break existing setups. After that, the versioning-warning in the
302302+ <literal>nextcloud</literal>-module should be updated to make sure
303303+ that the
304304+ <link linkend="opt-services.nextcloud.package">package</link>-option
305305+ selects the latest version on fresh setups.
306306+ </para>
307307+ <para>
308308+ If major-releases will be abandoned by upstream, we should check
309309+ first if those are needed in NixOS for a safe upgrade-path before
310310+ removing those. In that case we should keep those packages, but
311311+ mark them as insecure in an expression like this (in
312312+ <literal><nixpkgs/pkgs/servers/nextcloud/default.nix></literal>):
313313+ </para>
314314+ <programlisting>
294315/* ... */
295316{
296317 nextcloud17 = generic {
297297- version = "17.0.x";
298298- sha256 = "0000000000000000000000000000000000000000000000000000";
318318+ version = "17.0.x";
319319+ sha256 = "0000000000000000000000000000000000000000000000000000";
299320 eol = true;
300321 };
301322}
302323</programlisting>
303303- </para>
304304-305305- <para>
306306- Ideally we should make sure that it's possible to jump two NixOS versions forward:
307307- i.e. the warnings and the logic in the module should guard a user to upgrade from a
308308- Nextcloud on e.g. 19.09 to a Nextcloud on 20.09.
309309- </para>
310310- </section>
324324+ <para>
325325+ Ideally we should make sure that it's possible to jump two NixOS
326326+ versions forward: i.e. the warnings and the logic in the module
327327+ should guard a user to upgrade from a Nextcloud on e.g. 19.09 to a
328328+ Nextcloud on 20.09.
329329+ </para>
330330+ </section>
311331</chapter>