{ lib, namespace, ... }:
with lib;
let
  inherit (lib.${namespace}) mkOpt;
in
{
  options.${namespace}.services.traefik = {
    enable = mkEnableOption "enable traefik";

    extraServices = mkOpt (types.listOf (
      types.submodule {
        options = {
          name = mkOpt types.str "" "Name of the service";
          url = mkOpt types.str "http://localhost:8080" "Url of the service";
        };
      }
    )) [ ] "List of extra services to forward";

    extraRouters = mkOpt (types.listOf (
      types.submodule {
        options = {
          entryPoints = mkOpt (types.listOf types.str) [ "websecure" ] "Entrypoint";
          subdomain = mkOpt types.str "" "subdomain of the service";
          service = mkOpt types.str "" "name of the service";
          middlewares = mkOpt (types.listOf (
            types.enum [
              "authentik"
              "onlyoffice-websocket"
              "crowdsec"
              "whitelist-geoblock"
              "internal-ipallowlist"
            ]
          )) [ ] "List of middlewares to enable";
        };
      }
    )) [ ] "List of extra services to forward";

    reverseProxies =
      mkOpt (types.listOf types.attrs) [ ]
        "List of reverse proxy configurations from mkReverseProxy";
  };
}
