{
  config,
  lib,
  namespace,
  ...
}:
let

  cfg = config.${namespace}.services.onlyoffice;

  jwtSecretFile = config.sops.secrets."jallen-nas/onlyoffice-key".path;
in
{
  options.${namespace}.services.onlyoffice = {
    enable = lib.mkEnableOption "";
  };

  config = lib.mkIf cfg.enable {
    services.nginx.virtualHosts."office.mjallen.dev".listen = [
      {
        addr = "0.0.0.0";
        port = 9943;
      }
    ];
    services.onlyoffice = {
      enable = true;
      port = 9943;
      hostname = "office.mjallen.dev";
      jwtSecretFile = jwtSecretFile;
    };
  };
}
