Commit Graph

244 Commits

Author SHA1 Message Date
stuebinm
6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
Ilan Joselevich
9353fb2309
nixos/nextcloud: remove opcache.enable_cli=1
Upstream no longer recommends enabling the opcache cli.
See the following:
 - https://github.com/nextcloud/documentation/issues/1439
 - https://github.com/nextcloud/server/pull/15468
2024-03-14 18:36:11 +02:00
Sandro Jäckel
907b5ebcee
nixos/nextcloud: build with-apps local 2024-03-02 18:01:38 +01:00
Sandro Jäckel
c64c45da9c
nixos/nextcloud: don't execute cron when in maintenace/upgrade, don't kill cgroup
Those are upstream recommendations taken from
22d2472b8f/admin_manual/configuration_server/background_jobs_configuration.rst (systemd)
2024-02-05 01:29:13 +01:00
Sandro Jäckel
42daa00928
nixos/nextcloud: little formatting 2024-02-05 01:29:13 +01:00
Jonas Heinrich
e1c0d281b2 nixos/nextcloud: Rename extraOptions to settings 2024-01-26 14:22:49 +01:00
Maximilian Bosch
93d692f43b
Merge pull request #280600 from Ma27/nextcloud-state-tmpfiles
nixos/nextcloud: set up base directories & override.config.php with tmpfiles
2024-01-20 17:49:46 +01:00
Maximilian Bosch
90787dbe89
nixos/nextcloud: set up base directories & override.config.php with tmpfiles
Closes #169733

The issue is that Nextcloud fails to start up after a GC because the
symlink from `override.config.php` is stale.

I'm relatively certain that this is not a bug in the Nix GC - that
would've popped up somewhere else already in the past years - and one of
the reporters seems to confirm that: when they restarted
`nextcloud-setup.service` after the issue appeared, an
`override.config.php` pointing to a different hash was there.

This hints that on a deploy `nextcloud-setup` wasn't restarted properly
and thus replacing the symlink update was missed. This is relatively
hard to trigger due to the nature of the bug unfortunately (you usually
keep system generations for a few weeks and you'll need to change the
configuration - or stdenv - to get a different `override.config.php`),
so getting pointers from folks who are affected is rather complicated.

So I decided to work around this by using systemd-tmpfiles which a lot
of other modules already utilize for this use-case. Now,
`override.config.php` and the directory structure aren't created by
`nextcloud-setup`, but by `systemd-tmpfiles`.

With that, the structure is guaranteed to exist

* on boot, since tmpfiles are always created/applied then
* on config activation, since this is done before services are
  (re)started which covers the case for new installations and existing
  ones.

Also, the recursive `chgrp` was used as transition tool when we switched
from `nginx` as owning group to a dedicated `nextcloud` group[1][2], but
this was several releases ago, so I don't consider this relevant
anymore.

[1] fd9eb16b24
[2] ca916e8cb3
2024-01-12 22:11:36 +01:00
Jonas Heinrich
6707b97f00 nixos/nextcloud: Remove old migration warnings 2024-01-09 20:59:03 +01:00
Maximilian Bosch
e55b4c1ec7
Merge pull request #278493 from marrobHD/patch-1
nixos/nextcloud: fix dbport in config.php
2024-01-06 16:26:15 +01:00
May
5be349d0be
nixos/nextcloud: remove dbport
To specify a port for the database host, `host:port` format has to be used [1].

[1]: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#dbhost
2024-01-04 12:34:24 +01:00
Jonas Heinrich
818fdce3d0 nixos/nextcloud: Fix corrent option name 2024-01-03 14:08:21 +01:00
Patrick Steinhardt
f026ea0db0 nixos/nextcloud: disable output buffering
The Nextcloud admin guide says that output buffering must be turned off
or otherwise PHP will return memory-related errors [1]. As the default
value for this PHP setting is 4096 and thus enabled the Nextcloud setup
is thus misconfigured by default. This misconfiguration will be shown in
the "Security & setup warnings" dialog for the administrator.

Fix this misconfiguration by setting "output_buffering=0" by default.

[1]: https://docs.nextcloud.com/server/stable/admin_manual/configuration_files/big_file_upload_configuration.html#configuring-php
2024-01-02 08:45:42 +01:00
Maximilian Bosch
d25fdec5b3
Merge pull request #212430 from onny/nextcloud-cleanup
nixos/nextcloud: Move options into now freeForm extraOptions
2023-12-29 23:44:24 +01:00
Maximilian Bosch
bae5e65162
nixos/nextcloud: fix nginx routing to store and nix apps
Closes #277206

The bug mentioned above was a symptom of the issue fixed here: when
opening the `forms` app which is installed via `extraApps` (or the
app store) the site wouldn't work because `.mjs` files had the wrong
Content-Type.

The actual problem got fixed already[1], however this config was not
used for stuff from `/nix-apps` & `/store-apps` which had their own
location section with only a `root ;` statement.

In fact, this setup isn't strictly supported by Nextcloud upstream[2],
so to fix this for good, I decided to follow the upstream suggestion for
app directories outside the server root, i.e. linking them back into the
store path.

This means that the module generates a new derivation now with

* `services.nextcloud.package` linked into it via `lndir`.
* under `nix-apps` is a symlink to the link farm containing all apps
  from `services.nextcloud.extraApps`.
* under `store-apps` is a symlink to `/var/lib/nextcloud/store-apps`.
  Since this is only used in the NixOS module that also configures this
  location for imperatively installed apps, this seems an OK thing to
  do.

Successfully tested the change on a productive Nextcloud 28.0.1 with
several apps installed via `extraApps` (`forms`, `cospend`, `maps`,
`user_saml` and a few more).

[1] 292c74c7a9
[2] https://docs.nextcloud.com/server/28/admin_manual/apps_management.html#using-custom-app-directories
2023-12-29 18:59:18 +01:00
Jonas Heinrich
dd8c96379f nixos/nextcloud: Move options into now freeForm extraOptions 2023-12-29 01:04:46 +01:00
Ilan Joselevich
8bbbb228b4
nixos/nextcloud: serve flac and ogg files
Since v28 Nextcloud Talk supports serving files with with .ogg/.flac extension
2023-12-19 13:07:19 +02:00
Daniel Thwaites
292c74c7a9
nixos/nextcloud: set correct MIME type for .mjs files 2023-12-17 19:17:10 +00:00
Maximilian Bosch
f718012d92
nixos/nextcloud: updates for nc28
* Always use PHP 8.2: at the time of writing, Nextcloud also suggests to
  use 8.2 rather than 8.3 in the manual for v28.

  One contributing factor is probably that all plugins need new releases
  to declare PHP 8.3 support.

* Fix upgradeWarning for installing v27 now that v28 is out.

* Drop upgrade warning for v24. This one is EOL for quite a while
  already, so right now everybody should've switched (or carefully
  studied the release notes in case they were upgrading from <23.05) and
  we can clean up the module a little bit.

  v25 was dropped not so long ago, so if it's still referenced (because
  somebody didn't declare `services.nextcloud.package` and has
  `system.stateVersion = "22.11";`) it's appropriate to still give a
  specialized error.
2023-12-14 17:32:55 +01:00
Robert Schütz
f6ea3f91b5 nextcloud28: init at 28.0.0 2023-12-13 15:57:33 -08:00
Maximilian Bosch
9f9de7c5e3
Merge pull request #272919 from SuperSandro2000/nextcloud
nixos/nextcloud: allow phpOptions to contain ints
2023-12-10 12:49:52 +01:00
Maximilian Bosch
2ee3ddef8c
Merge pull request #266935 from s-sinnlos/nextcloud26-ocm-dir-fix
nixos/nextcloud: missing ocm-dir applys also from 26.0.8 onward
2023-12-09 14:00:59 +01:00
Sandro Jäckel
eaa581b5c3
nixos/nextcloud: allow phpOptions to contain ints 2023-12-08 15:03:09 +01:00
h7x4
0a37316d6c
treewide: use mkPackageOption
This commit replaces a lot of usages of `mkOption` with the package
type, to be `mkPackageOption`, in order to reduce the amount of code.
2023-11-27 01:28:36 +01:00
Felix Buehler
7f9abdcfcb nixos/nextcloud: fix docu of packages 2023-11-17 23:16:23 +01:00
Maximilian Bosch
48459567ae nixos/postgresql: drop ensurePermissions, fix ensureUsers for postgresql15
Closes #216989

First of all, a bit of context: in PostgreSQL, newly created users don't
have the CREATE privilege on the public schema of a database even with
`ALL PRIVILEGES` granted via `ensurePermissions` which is how most of
the DB users are currently set up "declaratively"[1]. This means e.g. a
freshly deployed Nextcloud service will break early because Nextcloud
itself cannot CREATE any tables in the public schema anymore.

The other issue here is that `ensurePermissions` is a mere hack. It's
effectively a mixture of SQL code (e.g. `DATABASE foo` is relying on how
a value is substituted in a query. You'd have to parse a subset of SQL
to actually know which object are permissions granted to for a user).

After analyzing the existing modules I realized that in every case with
a single exception[2] the UNIX system user is equal to the db user is
equal to the db name and I don't see a compelling reason why people
would change that in 99% of the cases. In fact, some modules would even
break if you'd change that because the declarations of the system user &
the db user are mixed up[3].

So I decided to go with something new which restricts the ways to use
`ensure*` options rather than expanding those[4]. Effectively this means
that

* The DB user _must_ be equal to the DB name.
* Permissions are granted via `ensureDBOwnerhip` for an attribute-set in
  `ensureUsers`. That way, the user is actually the owner and can
  perform `CREATE`.
* For such a postgres user, a database must be declared in
  `ensureDatabases`.

For anything else, a custom state management should be implemented. This
can either be `initialScript`, doing it manual, outside of the module or
by implementing proper state management for postgresql[5], but the
current state of `ensure*` isn't even declarative, but a convergent tool
which is what Nix actually claims to _not_ do.

Regarding existing setups: there are effectively two options:

* Leave everything as-is (assuming that system user == db user == db
  name): then the DB user will automatically become the DB owner and
  everything else stays the same.

* Drop the `createDatabase = true;` declarations: nothing will change
  because a removal of `ensure*` statements is ignored, so it doesn't
  matter at all whether this option is kept after the first deploy (and
  later on you'd usually restore from backups anyways).

  The DB user isn't the owner of the DB then, but for an existing setup
  this is irrelevant because CREATE on the public schema isn't revoked
  from existing users (only not granted for new users).

[1] not really declarative though because removals of these statements
    are simply ignored for instance: https://github.com/NixOS/nixpkgs/issues/206467
[2] `services.invidious`: I removed the `ensure*` part temporarily
    because it IMHO falls into the category "manage the state on your
    own" (see the commit message). See also
    https://github.com/NixOS/nixpkgs/pull/265857
[3] e.g. roundcube had `"DATABASE ${cfg.database.username}" = "ALL PRIVILEGES";`
[4] As opposed to other changes that are considered a potential fix, but
    also add more things like collation for DBs or passwords that are
    _never_ touched again when changing those.
[5] As suggested in e.g. https://github.com/NixOS/nixpkgs/issues/206467
2023-11-13 17:16:25 +01:00
Sebastian Sinnlos
71dd9c3d53 nixos/nextcloud: missing ocm-dir applys also from 26.0.8 onward
ocmProviderIsNotAStaticDirAnymore applys also to nextcloud26 form 26.0.8
onwards til EOL in 2024-03
2023-11-12 01:11:00 +01:00
Maximilian Bosch
ad57ad1ff5
nixos/nextcloud: update / clean up the nginx configuration
First of all, a few cleanups were made to make it more readable:

* Reordered the sections by their priority so what you're reading in Nix
  is also what you get in the final nginx.conf.
* Unified media/asset locations

Most notably, this fixes the

    Your web server is not properly set up to resolve "/ocm-provider/".

warning since 27.1.2 where `ocm-provider` was moved from a static
directory in the source tarball to a dynamic HTTP route[1].

Additionally, the following things were fixed:

* The 404 checks for build/tests/etc. are now guaranteed to be before
  the `.php` location match and it's not implicitly relied upon Nix's
  internal attribute sorting anymore.

* `.wasm` files are supported properly and a correct `Content-Type` is
  set.

* For "legacy" routes (e.g. `ocs-provider`/`cron`/etc) a `rewrite` rule
  inside the location for fastcgi is used as recommended by upstream[2].
  This also makes it easier to understand the purpose of the location
  itself (i.e. use fastcgi for PHP code).

[1] https://github.com/nextcloud/documentation/pull/11179
[2] https://docs.nextcloud.com/server/27/admin_manual/installation/nginx.html
2023-10-09 12:40:57 +02:00
Maximilian Bosch
8702ae0110
nixos/nextcloud: drop enableBrokenCiphersForSSE
🎉
2023-10-09 12:40:57 +02:00
Maximilian Bosch
efc5c80e18
nextcloud25: remove
EOL of Nextcloud v25 is scheduled by the end of this month.
2023-10-07 16:16:42 +02:00
Maximilian Bosch
648546b09d
nixos/nextcloud: improve documentation of adminuser-option
This option only has an effect on the initial setup of Nextcloud and
changes later won't have any effect.

Same issue as with `adminpassFile` - it's only passed to the installer
command - but even worse because the username is frequently used as
unique ID in the database, so there's no trivial way to change it, even
imperatively.
2023-08-07 12:16:41 +02:00
Maximilian Bosch
01820d520b
Merge pull request #247384 from jtbx/nextcloud-doc
nixos/nextcloud: improve documentation
2023-08-06 12:27:33 +02:00
Jeremy
c7a9f7c132 nixos/nextcloud: improve documentation 2023-08-06 10:02:52 +12:00
Maximilian Bosch
2ddb1453e6
nixos/nextcloud: make php settings additive
Right now, the settings aren't additive which means that when I do

    services.nextcloud.phpOptions."opcache.interned_strings_buffer = "23";

all other options are discarded because of how the module system works.

This isn't very nice in this case, though because wanting to override
a single option doesn't mean I want to discard the rest of the -
reasonable - defaults. Hence, the settings are showed as default in the
option's manual section, but are added with normal priority.

That means, to override _all_ options at once, an expression like

    services.nextcloud.phpOptions = mkForce {
      /* ... */
    };

is needed. This is also way more intuitive IMHO because the `mkForce`
explicitly tells that everything will be modified.

Also, APCu enable and the memory & file-size limits are also written
into `services.nextcloud.phpOptions` rather than adding them
silently before passing all options to the PHP package. This has the
benefit that users will realize on evaluation time that they configured
options that would otherwise be set by the module on its own.
2023-08-05 11:58:11 +02:00
Thomas Gerbet
84c0cb1471 php: drop PHP 8.0
Closes #224505
2023-06-21 22:09:16 +02:00
Maximilian Bosch
3df3a89892
nixos/nextcloud: fix declarative cache configuration
It's supposed to be `memcache.distributed`, not an associative PHP array
named `memcache` with a key `distributed`.

This was probably never caught because the initial `grep -q` check in
the test was invalid: `redis-cli` prints nothing if no keys can be found
when not writing to a tty apparently.
2023-06-16 14:11:38 +02:00
Maximilian Bosch
5a2769d981
nextcloud27: init
Fixes #237560
2023-06-16 14:11:38 +02:00
Doron Behar
5b6c95c4cb nixos/nextcloud: Mention that adminpassFile is only used on startup 2023-06-01 15:43:51 +03:00
figsoda
701bcdbead nixos: fix typos 2023-05-19 22:31:04 -04:00
Ryan Lahfa
fa06a3b646
Merge pull request #230888 from Misterio77/nextcloud-createlocally-optin
nixos/nextcloud: default createLocally to false
2023-05-15 09:28:15 +02:00
Gabriel Fontes
f9f76529cd
nixos/nextcloud: default createLocally to false 2023-05-14 12:09:50 -03:00
Sandro Jäckel
546d4d4b76
nixos/nextcloud: add configureRedis option 2023-05-03 22:40:41 +02:00
Gabriel Fontes
fddf531c6f
nixos/nextcloud: refactor database.createLocally
Fixes https://github.com/NixOS/nixpkgs/issues/228971
2023-05-01 12:20:40 -03:00
Maximilian Bosch
0abc5bcc7e
nixos/nextcloud: for nc26 it's not necessary anymore to set enableBrokenCiphersForSSE to false 2023-04-20 12:20:52 +02:00
Maximilian Bosch
430f1dcdbd
nextcloud: remove nextcloud24, 25.0.5 -> 25.0.6, 26.0.0 -> 26.0.1 2023-04-20 11:34:54 +02:00
Robert Schütz
15b859cefe nixos/nextcloud: set X-Robots-Tag to "noindex, nofollow"
Upstream did so in https://github.com/nextcloud/server/pull/36689 and
Nextcloud now complains that

    The "X-Robots-Tag" HTTP header is not set to "noindex, nofollow".
    This is a potential security or privacy risk, as it is recommended
    to adjust this setting accordingly.
2023-03-25 19:48:13 -07:00
Maximilian Bosch
cbc539c19f nixos/nextcloud: minor fixups
* Apply review comments.
* Default to PHP 8.2 for v26.
2023-03-22 22:37:17 +01:00
Maximilian Bosch
6a0b0a5de9 nextcloud: remove compat references to v23
This is not needed anymore because the version is EOL for almost a year
now and we don't even have the packages anymore, only the attributes for
compatibility for upgrades from older NixOS versions.
2023-03-22 22:37:17 +01:00
Raito Bezarius
dd96b7d8b4 nextcloud26, nixos/web-apps/nextcloud: drop the autocreate db user patch and wire the default in the NixOS module 2023-03-22 22:37:16 +01:00
Raito Bezarius
5e5c4c975a nixos/web-apps/nextcloud: introduce nextcloud26 2023-03-22 22:37:13 +01:00