{ pkgs, config, lib, ... }:
let
  wordpressPort = 5781;
in
{
  config = lib.mkMerge [
    (lib.mkIf (config.networking.hostName == "nixnas") {
      services.wordpress.sites."bikeability.net" = {
        virtualHost.listen = [{
          port = wordpressPort;
          ip = "127.0.0.1";
        }];
        settings = {
          FORCE_SSL_ADMIN = true;
        };
        extraConfig = ''
          $_SERVER['HTTPS']='on';
        '';
        plugins = {
          wpcode = pkgs.stdenv.mkDerivation rec {
            name = "wpcode";
            version = "2.3.3";
            src = pkgs.fetchzip {
              url = "https://downloads.wordpress.org/plugins/insert-headers-and-footers.${version}.zip";
              hash = "sha256-BjQ62ZvWck/e0kcP6Ny1pOGAfsPVUDQLrvGnvkeq6FY=";
            };
            installPhase = "mkdir -p $out; cp -R * $out/";
          };
        };
      };
      services.cloudflared.tunnels.mine.ingress."bikeability.net" = "http://127.0.0.1:${builtins.toString wordpressPort}";
    })
  ];
}
