self:
{ config, lib, ... }:

let
  cfg = config.services.jetpham-website;
  package = self.packages.x86_64-linux.default;
in
{
  options.services.jetpham-website = {
    enable = lib.mkEnableOption "Jet Pham's personal website";

    domain = lib.mkOption {
      type = lib.types.str;
      default = "jetpham.com";
      description = "Domain to serve the website on.";
    };
  };

  config = lib.mkIf cfg.enable {
    services.caddy.virtualHosts.${cfg.domain} = {
      extraConfig = ''
        header Cross-Origin-Opener-Policy "same-origin"
        header Cross-Origin-Embedder-Policy "require-corp"
        root * ${package}
        file_server
      '';
    };
  };
}
