I tried using the snippet from NixOS wiki and it didn’t work. Then I found another snippet from here The Holy Grail Nextcloud setup made easy by NixOS · Carlos Vaz and changed a few things. Now I’m getting a NextCloud not installed error when nextcloud-setup.service tries to boot.
warning: the following units failed: nextcloud-setup.service
× nextcloud-setup.service
Loaded: loaded (/etc/systemd/system/nextcloud-setup.service; enabled; preset: ignored)
Active: failed (Result: exit-code) since Thu 2025-02-20 18:33:13 JST; 368ms ago
Invocation: b0da9989113c4321a593dba6a8710edc
Process: 62747 ExecStart=/nix/store/5ki5899f46d8fckjl9bj56yk2cy4qa54-unit-script-nextcloud-setup-start/bin/nextcloud-setup-start (code=exited, status=1/FAILURE)
Main PID: 62747 (code=exited, status=1/FAILURE)
IP: 0B in, 0B out
IO: 17.7M read, 0B written
Mem peak: 38.2M
CPU: 220ms
Feb 20 18:33:13 PikaNix systemd[1]: Starting nextcloud-setup.service...
Feb 20 18:33:13 PikaNix nextcloud-setup-start[62761]: Nextcloud is not installed - only a limited number of commands are available
Feb 20 18:33:13 PikaNix nextcloud-setup-start[62761]:
Feb 20 18:33:13 PikaNix nextcloud-setup-start[62761]: Command "upgrade" is not defined.
Feb 20 18:33:13 PikaNix nextcloud-setup-start[62761]:
Feb 20 18:33:13 PikaNix systemd[1]: nextcloud-setup.service: Main process exited, code=exited, status=1/FAILURE
Feb 20 18:33:13 PikaNix systemd[1]: nextcloud-setup.service: Failed with result 'exit-code'.
Feb 20 18:33:13 PikaNix systemd[1]: Failed to start nextcloud-setup.service.
Feb 20 18:33:13 PikaNix systemd[1]: nextcloud-setup.service: Consumed 220ms CPU time, 38.2M memory peak, 17.7M read from disk.
warning: error(s) occurred while switching to the new configuration
This is what the NextCloud section of my configuration.nix looks like now:
services.nextcloud = {
enable = true;
hostName = "localhost";
# Need to manually increment with every major upgrade.
package = pkgs.nextcloud29;
# Let NixOS install and configure the database automatically.
database.createLocally = true;
# Increase the maximum file upload size to avoid problems uploading videos.
maxUploadSize = "16G";
https = true;
autoUpdateApps.enable = true;
extraAppsEnable = true;
extraApps = with config.services.nextcloud.package.packages.apps; {
# List of apps we want to install and are already packaged in
# https://github.com/NixOS/nixpkgs/blob/59236c424f78565cddaf8dd24d3703de358496b8/pkgs/servers/nextcloud/packages/nextcloud-apps.json
inherit (config.services.nextcloud.package.packages.apps) previewgenerator;
# Custom app installation example.
# cookbook = pkgs.fetchNextcloudApp rec {
# url = "https://github.com/nextcloud/cookbook/releases/download/v0.10.2/Cookbook-0.10.2.tar.gz";
# sha256 = "sha256-XgBwUr26qW6wvqhrnhhhhcN4wkI+eXDHnNSm1HDbP6M=";
# license = "MIT";
# };
};
config = {
dbtype = "pgsql";
adminuser = "admin";
adminpassFile = "/etc/nextcloudadminpass";
};
};