Nextcloud: Difference between revisions
Redis caching is now enabled as default with NixOS 25.11 |
No edit summary |
||
| (9 intermediate revisions by 6 users not shown) | |||
| Line 13: | Line 13: | ||
hostName = "localhost"; | hostName = "localhost"; | ||
config.adminpassFile = "/etc/nextcloud-admin-pass"; | config.adminpassFile = "/etc/nextcloud-admin-pass"; | ||
config.dbtype = "sqlite"; | |||
settings = { | |||
# Some sane defaults required to satisfy Nextcloud configuration check | |||
maintenance_window_start = 1; | |||
default_phone_region = "DE"; | |||
log_type = "systemd"; | |||
serverid = 0; | |||
}; | |||
}; | }; | ||
</nowiki>}} | </nowiki>|name=/etc/nixos/configuration.nix|lang=nix}} | ||
After that you will be able to login into your Nextcloud instance at <code><nowiki>http://localhost</nowiki></code> with user <code>root</code> and password <code>PWD</code> as configured above. | After that you will be able to login into your Nextcloud instance at <code><nowiki>http://localhost</nowiki></code> with user <code>root</code> and password <code>PWD</code> as configured above. | ||
| Line 24: | Line 32: | ||
=== Apps === | === Apps === | ||
[https://github.com/NixOS/nixpkgs/blob/ | [https://github.com/NixOS/nixpkgs/blob/0d7bf2685cc69bcb51430bbc0493e221f9c21c2d/pkgs/servers/nextcloud/packages/34.json Some apps] (use the file named <code><version>.json</code>, where version is the installed Nextcloud version), which are already packaged on NixOS, can be installed directly with the following example configuration: | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
| Line 30: | Line 38: | ||
enable = true; | enable = true; | ||
[...] | [...] | ||
# Instead of using pkgs. | # Instead of using pkgs.nextcloud34Packages.apps or similar, | ||
# we'll reference the package version specified in services.nextcloud.package | # we'll reference the package version specified in services.nextcloud.package | ||
extraApps = { | extraApps = { | ||
| Line 37: | Line 45: | ||
extraAppsEnable = true; | extraAppsEnable = true; | ||
}; | }; | ||
</nowiki>}} | </nowiki>|name=/etc/nixos/configuration.nix|lang=nix}} | ||
The apps mail, news and contacts will be installed and enabled in your instance automatically. Note that the Nextcloud version specified in <code>package</code> and <code>extraApps</code> need to match one of the stable Nextcloud versions available in the NixOS repository. | The apps mail, news and contacts will be installed and enabled in your instance automatically. Note that the Nextcloud version specified in <code>package</code> and <code>extraApps</code> need to match one of the stable Nextcloud versions available in the NixOS repository. | ||
| Line 127: | Line 135: | ||
In this example we'll configure a local S3-compatible object store using Minio and connect it to Nextcloud | In this example we'll configure a local S3-compatible object store using Minio and connect it to Nextcloud | ||
{{file| | {{file|||<nowiki> | ||
{ ... } let | { ... } let | ||
| Line 144: | Line 152: | ||
enable = true; | enable = true; | ||
bucket = "nextcloud"; | bucket = "nextcloud"; | ||
verify_bucket_exists = true; | |||
key = accessKey; | key = accessKey; | ||
secretFile = "${pkgs.writeText "secret" "test12345"}"; | secretFile = "${pkgs.writeText "secret" "test12345"}"; | ||
| Line 165: | Line 173: | ||
}; | }; | ||
</nowiki>}} | </nowiki>|name=/etc/nixos/configuration.nix|lang=nix}} | ||
We'll need to run two commands to create the bucket <code>nextcloud</code> by using the access key <code>nextcloud</code> and the secret key <code>test12345</code>. | We'll need to run two commands to create the bucket <code>nextcloud</code> by using the access key <code>nextcloud</code> and the secret key <code>test12345</code>. | ||
| Line 334: | Line 342: | ||
services.nginx.virtualHosts."${config.services.nextcloud.hostName}".listen = [ { addr = "127.0.0.1"; port = 8080; } ]; | services.nginx.virtualHosts."${config.services.nextcloud.hostName}".listen = [ { addr = "127.0.0.1"; port = 8080; } ]; | ||
</nowiki>}} | </nowiki>}} | ||
=== Enable Two-factor authentication === | |||
Two-factor authentication can be enabled for your server via the administration interface in your browser. There is no way to declare this setting via nix configuration, so you should follow the [https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/two_factor-auth.html official documentation] to set up Two-factor authentication. | |||
=== Enable HEIC image preview === | === Enable HEIC image preview === | ||
| Line 485: | Line 497: | ||
=== Whiteboard === | === Whiteboard === | ||
The [https://github.com/nextcloud/whiteboard Whiteboard app] requires a running backend server which is also packaged in NixOS.<syntaxhighlight lang="nix"> | The [https://github.com/nextcloud/whiteboard Whiteboard app] requires a running backend server which is also packaged in NixOS.<syntaxhighlight lang="nix">environment.etc."nextcloud-whiteboard-secret".text = '' | ||
environment.etc."nextcloud-whiteboard-secret".text = '' | |||
JWT_SECRET_KEY=test123 | JWT_SECRET_KEY=test123 | ||
''; | ''; | ||
| Line 495: | Line 506: | ||
secrets = [ /etc/nextcloud-whiteboard-secret ]; | secrets = [ /etc/nextcloud-whiteboard-secret ]; | ||
}; | }; | ||
</syntaxhighlight>After applying the configuration configure the Nextcloud app to use it<syntaxhighlight lang="bash"> | |||
nextcloud-occ config:app:set whiteboard collabBackendUrl --value="http://localhost:3002" | # Expose whiteboard server in case you don’t operate your Nextcloud on localhost | ||
nextcloud-occ config:app:set whiteboard jwt_secret_key --value="test123" | services.nginx.virtualHosts.${config.services.nextcloud.hostName}.locations."/whiteboard/" = { | ||
</syntaxhighlight> | proxyPass = "http://localhost:3002/"; | ||
proxyWebsockets = true; | |||
};</syntaxhighlight>After applying the configuration configure the Nextcloud app to use it<syntaxhighlight lang="bash"> | |||
nextcloud-occ config:app:set whiteboard collabBackendUrl --value="http://localhost:3002" # localhost only | |||
nextcloud-occ config:app:set whiteboard collabBackendUrl --value="http://cloud.example.com/whiteboard" # Public (The domain is your Nextcloud hostname) | |||
nextcloud-occ config:app:set whiteboard jwt_secret_key --value="test123"</syntaxhighlight> | |||
=== NextCloud Office === | === NextCloud Office === | ||
| Line 537: | Line 553: | ||
For easy deployment, there's the [https://apps.nextcloud.com/apps/richdocumentscode richdocumentscode app] which bundles the CODE server. While being less performant than a standalone deployment of the CODE server, this solution does not require an additional service to be deployed and managed externally from NextCloud. Unfortunately the richdocumentscode app bundles the CODE server as an AppImage and therefore does not work out of the box on NixOS. Follow https://github.com/NixOS/nixpkgs/issues/339798 if you want to get informed about packaging progress. Also CODE standalone is currently not packaged in nixpkgs (https://github.com/NixOS/nixpkgs/issues/218878). | For easy deployment, there's the [https://apps.nextcloud.com/apps/richdocumentscode richdocumentscode app] which bundles the CODE server. While being less performant than a standalone deployment of the CODE server, this solution does not require an additional service to be deployed and managed externally from NextCloud. Unfortunately the richdocumentscode app bundles the CODE server as an AppImage and therefore does not work out of the box on NixOS. Follow https://github.com/NixOS/nixpkgs/issues/339798 if you want to get informed about packaging progress. Also CODE standalone is currently not packaged in nixpkgs (https://github.com/NixOS/nixpkgs/issues/218878). | ||
=== Memories === | |||
To enable hardware acceleration, nextcloud will need access to the graphics card with e.g:<syntaxhighlight lang="nix"> | |||
users.users.nextcloud.extraGroups = [ "video" ]; | |||
systemd.services.phpfpm-nextcloud.serviceConfig = { | |||
DeviceAllow = "/dev/dri/renderD128 rw"; | |||
PrivateDevices = lib.mkForce false; | |||
}; | |||
</syntaxhighlight>You will still need to enable the relevant app configuration through "Administration Settings > Memories > HW Acceleration". | |||
[[Category:Server]] | [[Category:Server]] | ||
[[Category:Applications]] | [[Category:Applications]] | ||
[[Category:Web Applications]] | [[Category:Web Applications]] | ||
[[Category:NixOS Manual]] | [[Category:NixOS Manual]] | ||