{ config, lib, pkgs, ... }: let cfg = config.orbekk.nextcloud; in { options = { orbekk.nextcloud = { enable = lib.mkEnableOption "Enable nextcloud server"; }; }; config = lib.mkIf cfg.enable { services.nextcloud = { enable = true; package = pkgs.nextcloud26; hostName = "nextcloud.orbekk.com"; home = "/storage/nextcloud"; enableBrokenCiphersForSSE = false; config = { dbtype = "pgsql"; dbuser = "nextcloud"; dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself dbname = "nextcloud"; adminpassFile = "/opt/secret/nextcloud/admin-pass-file"; adminuser = "root"; }; maxUploadSize = "16G"; autoUpdateApps.enable = true; https = true; }; services.postgresql = { enable = true; ensureDatabases = [ "nextcloud" ]; ensureUsers = [ { name = "nextcloud"; ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES"; } ]; }; users.extraUsers.nextcloud.extraGroups = ["readonly"]; systemd.services."nextcloud-setup" = { requires = ["postgresql.service"]; after = ["postgresql.service"]; }; }; }