{ config, pkgs, lib, mkDomain, ... }:
{
  # Roundcube
  # Open Source Webmail Software

  services.roundcube = {
    enable = true;
    hostName = mkDomain "roundcube";
    plugins = [
      "archive"
      "zipdownload"
      "managesieve"
    ];
    extraConfig = ''
      $config['product_name'] = 'Spis meg';
      $config['skin_logo'] = [
        #'elastic:login' => 'https://links.pbsds.net/img/piuy_render.png',
        #'elastic:*[small]' => 'https://links.pbsds.net/img/piuy_render.png',
        'elastic:*' => 'https://links.pbsds.net/img/piuy_render.png',
        #'elastic:*' => 'https://links.pbsds.net/img/nox.png',
      ];
      #$config['blankpage_url'] = '/something.html' # TODO <-
      $config['default_host'] = [
        'tls://imap.fyrkat.no' => 'Fyrkat',
        'tls://imap.pvv.ntnu.no' => 'PVV',
        'tls://imap.nvg.ntnu.no' => 'NVG',
      ];
      $config['smtp_server'] = [
        'imap.fyrkat.no'   => 'tls://smtp.fyrkat.no',
        'imap.pvv.ntnu.no' => 'tls://smtp.pvv.ntnu.no',
        'imap.nvg.ntnu.no' => 'tls://smtp.nvg.ntnu.no',
      ];
      # plugins/managesieve/config.inc.php.dist
      $config['managesieve_host'] = 'tls://%h';
    '';
  };
  services.nginx.virtualHosts.${mkDomain "roundcube"} = lib.mkIf config.services.roundcube.enable {
    forceSSL = true; # addSSL = true;
    enableACME = true; #useACMEHost = acmeDomain;
    locations."/skins/elastic/images/logo.svg" = {
      #alias = "/path/to/file";
      #return = "302 https://links.pbsds.net/img/piuy_render.png";
      return = "302 https://links.pbsds.net/img/nox.png";
    };
  };

}
