Commit Graph

265 Commits

Author SHA1 Message Date
Sandro Jäckel
1ada7c1d36
nixos/nextcloud: fix shellcheck findings with enableStrictShellChecks enabled 2024-10-14 18:20:25 +02:00
Peder Bergebakken Sundt
3100acba08 treewide: \xc2\xa0 ->
I have no idea what this escape sequence even is, but it breaks the nix parser with cryptic errors if not used in a comment.
A friend let me know MacOS is prone to input weird spaces, not sure if that is the source.

Candidates were located and created with:

    chr="$(echo -e '\xc2\xa0')"; rg -F "$chr" -l | xe sd -F "$chr" " "

There are some examples left, most being example output from `tree` in various markdown documents, some patches which we can't really touch, and `pkgs/tools/nix/nixos-render-docs/src/tests/test_commonmark.py` which I'm not sure if should be addressed
2024-10-02 15:33:06 +02:00
Maximilian Bosch
55a45406a6
nixos/nextcloud: update relatedPackages 2024-10-01 13:36:16 +02:00
Maximilian Bosch
20ed9ccd88
nextcloud: correct stateversion logic 2024-10-01 12:48:47 +02:00
Jonas Heinrich
1b121c1ea2
nextcloud30: init at 30.0.0 2024-10-01 12:48:45 +02:00
Mynacol
af072cfb55 nixos/nextcloud: Remove --preserve-env in sudo
This helps supporting sudo-rs, which currently does not implement the
--preserve-env flag and probably won't so in the foreseeable future [1].

The replacement just sets both environment variables behind the sudo
invocation with env, as sudo-rs also doesn't implement env var lists.

The OC_PASS variable is dropped, as it is seemingly unused and would
leak through this approach through /proc.

[1] https://github.com/memorysafety/sudo-rs/issues/129
2024-07-02 11:29:35 +02:00
Jonas Heinrich
77e7768849
Merge pull request #322397 from Ma27/bump-nextcloud
nextcloud: drop 27, 28.0.6 -> 28.0.7, 29.0.2 -> 29.0.3
2024-06-27 14:09:29 +02:00
Sandro
33f83c6252
Merge pull request #316977 from eclairevoyant/fix-mkEnableOption
treewide: fix mkEnableOption usage
2024-06-25 22:42:16 +02:00
Maximilian Bosch
60657a4591
nextcloud27: remove
Version will be EOL by the end of 2024-06.
2024-06-25 14:08:15 +02:00
Maximilian Bosch
2ac989c06f
Merge pull request #321931 from Ma27/occ-improvements
nixos/nextcloud: occ improvements
2024-06-23 17:42:42 +00:00
Maximilian Bosch
50d5306e7c
nixos/nextcloud: use dedicated memory limit for the entire CLI
Originally, I wanted to execute `nextcloud-occ` with a higher memory
limit because I needed to trigger an expensive operation by hand,
regenerating a bunch of previews.

While doing so, I realized how painful it is to put an invocation of
nextcloud-occ together for that, especially when you need to put it
into another systemd unit in Nix code.

That's why I decided to use the memory limit now for every
CLI invocation just in case. The stuff you do in those units (e.g.
running background jobs) is something you can also do by hand with
`nextcloud-occ` and you'll most likely want to have the same memory
limit there.
2024-06-22 18:39:08 +02:00
Maximilian Bosch
ab9b8f8cf4
nixos/nextcloud: services.nextcloud.occ is not internal
This option is actually useful when having a systemd unit invoking
`nextcloud-occ`, then you want to do something like

    path = [ config.services.nextcloud.occ ]

This is possible today, but not documented (and the option completion
from nil doesn't pick it up as a result).
2024-06-22 18:38:04 +02:00
Maximilian Bosch
45d2b8b536
nixos/nextcloud: deprecated dbtableprefix
Closes #320381

Installation with a custom dbtableprefix is not allowed anymore for a
while[1] and we shouldn't advertise it as such.

The option is deprecated for now since I'm not sure if there are some
weird corner-cases where removing the option directly would break
existing installations from before <20 with a custom dbtableprefix. The
migration-path for such a case is as follows:

* Check if /var/lib/nextcloud/config/config.php has the correct
  dbtableprefix set and if not, take care of it.
* Remove `dbtableprefix` from the NixOS configuration. It's effectively
  state anyways.

After a bit of time to switch (perhaps after the next release
branchoff), the option can be removed.

[1] https://github.com/nextcloud/server/issues/24836
2024-06-19 11:43:33 +02:00
éclairevoyant
7d8742da87
treewide: fix mkEnableOption usage 2024-06-14 02:41:42 -04:00
Maximilian Bosch
dddd08d188
nixos/nextcloud: make memory_limit of nextcloud-cron configurable
The memory limit is equal to what's configured in php-fpm. Given that we
run in a different environment, it seems reasonable to allow different
memory contraints here.
2024-05-30 23:38:55 +02:00
Robert Schütz
dce84c46d7 nixos/nextcloud: correct latest version 2024-05-16 08:53:01 -07:00
Jonas Heinrich
4a451cb3ce
Merge pull request #308291 from Ma27/nc-update-db
nixos/nextcloud: add nextcloud-update-db.service, nextcloud-cron isn't oneshot
2024-05-08 11:29:45 +02:00
Maximilian Bosch
c7a1616be7
nixos/nextcloud: add trailing slashes to carddav/caldav redirect
This seems to solve the problem with the warning about carddav/caldav
redirects being broken.
2024-05-05 18:17:25 +02:00
Maximilian Bosch
5ef467d6f5
nixos/nextcloud: add nextcloud-update-db.service, nextcloud-cron isn't oneshot
This service performs operations that significantly increase the
performance of Nextcloud, can take a while. These are designed however
to not require maintenance mode and can be executed during normal
operation[1].

Make nextcloud-cron a simple unit instead of oneshot: otherwise we risk
that it'll be stopped by the startup timeout (oneshot executes ExecStart
while "activating") which can be an issue for very long running tasks or
if Nextcloud needs to catch up if one task was broken for a while.

[1] https://docs.nextcloud.com/server/29/admin_manual/maintenance/upgrade.html#long-running-migration-steps
2024-05-01 20:09:37 +02:00
Maximilian Bosch
23f73fb2e6
nixos/nextcloud: php83 for nc29, update release notes
* PHP 8.3 seems supported, so let's go for it!

* The conditions for which Nextcloud will be the default were bogus: for
  <24.11 I'd suggest to go for nextcloud29 already. The people on
  unstable relying on the condition were on nextcloud28 so the upgrade
  will work fine.

  Also, it's unstable, so such upgrades are to be expected IMHO.

* Update the release notes to reflect that the new default is Nextcloud
  29 and warn that only one major upgrade at a time can be done.
2024-04-25 15:27:30 +02:00
Raito Bezarius
04e7710507
nixos/nextcloud: set 29 as default version for >= 24.11
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2024-04-25 15:27:30 +02:00
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