{ pkgs, config, ... }:
{
  imports = [ ./nginx ];

  services.nextcloud = {
    enable = config.system.server.enable;
    package = pkgs.nextcloud30;
    hostName = "cloud.${config.domains.p2}";
    datadir = "/mnt/nextcloud";
    https = true;
    config = {
      adminuser = "jimbo";
      adminpassFile = "/mnt/nextcloud/password.txt";
    };
    settings = {
      trusted_proxies = [ "127.0.0.1" ];
      trusted_domains = [ "cloud.${config.domains.p2}" ];
      overwriteprotocol = "https";
      mail_smtphost = "mx.${config.domains.p1}";
      mail_domain = "${config.domains.p1}";
      mail_from_address = "noreply";
      mail_smtpauth = "true";
      mail_smtpname = "noreply@${config.domains.p1}";
      mail_smtppassword = config.secrets.noreplyPassword;
      mail_smtpmode = "smtp";
      mail_smtpport = 587;
    };
  };
}
