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

  config = lib.mkIf config.services.lemmy.enable {
    services.lemmy = lib.mkIf config.services.lemmy.enable {
      nginx.enable = true;
      database.createLocally = true;
      settings = {
        hostname = "lemmy.nixfox.ca";
        email = {
          smtp_server = "mx.nixfox.ca:587";
          smtp_login = "noreply@nixfox.ca";
          smtp_from_address = "NixFox Lemmy <noreply@nixfox.ca>";
          smtp_password = config.secrets.mailPass.nixfoxNoReply;
          tls_type = "starttls";
        };
      };
    };
    environment.persistence."/persist".directories = [ "/var/lib/postgresql" ];
  };
}
