{ config, pkgs, lib, ... }: {
  sops.secrets.dawarich_smtp = {
    owner = config.services.dawarich.user;
    group = config.services.dawarich.group;
  };
  services.dawarich = {
    enable = true;
    package = (pkgs.callPackage ./dawarich/package.nix { }).overrideAttrs (old: {
      # https://github.com/Freika/dawarich/issues/1469
      postInstall = (old.postInstall or "") + ''
        cp ${./dawarich_smtp_config.rb} $out/config/initializers/smtp_settings.rb
      '';
    });
    webPort = 7392;
    configureNginx = false;
    localDomain = "location.crompton.cc";
    smtp = {
      fromAddress = "automated@syzygial.cc";
      user = "automated@syzygial.cc";
      passwordFile = config.sops.secrets.dawarich_smtp.path;
      host = "smtp.protonmail.ch";
      port = 587;
    };
  };

  services.caddy.virtualHosts = {
    ${config.services.dawarich.localDomain} = {
      extraConfig = ''
        reverse_proxy localhost:${toString config.services.dawarich.webPort}
#	encode brotli {
#          match {
#	    content_type text/css text/plain text/xml text/x-component text/javascript application/x-javascript application/javascript application/json application/manifest+json application/vnd.api+json application/xml application/xhtml+xml application/rss+xml application/atom+xml application/vnd.ms-fontobject application/x-font-ttf application/x-font-opentype application/x-font-truetype image/svg+xml image/x-icon image/vnd.microsoft.icon font/ttf font/eot font/otf font/opentype
#	  }
#	}
      '';
    };
  };  
}
