{
  lib,
  config,
  namespace,
  ...
}:
with lib;
let
  cfg = config.${namespace}.services.ocis;
in
{
  options.${namespace}.services.ocis = {
    enable = mkEnableOption "ownCloud Infinite Scale docker service";

    autoStart = mkOption {
      type = types.bool;
      default = true;
    };

    httpPort = mkOption {
      type = types.str;
      default = "9988";
    };

    name = mkOption {
      type = types.str;
      default = "ocis";
    };

    image = mkOption {
      type = types.str;
      default = "owncloud/ocis";
    };

    dataPath = mkOption {
      type = types.str;
      default = "/media/nas/main/ocis";
    };

    configPath = mkOption {
      type = types.str;
      default = "/media/nas/main/nix-app-data/ocis";
    };

    puid = mkOption {
      type = types.str;
      default = "911";
    };

    pgid = mkOption {
      type = types.str;
      default = "1000";
    };

    timeZone = mkOption {
      type = types.str;
      default = "America/Chicago";
    };
  };

  config = mkIf cfg.enable {
    virtualisation.oci-containers.containers."${cfg.name}" = {
      autoStart = cfg.autoStart;
      image = cfg.image;
      ports = [ "${cfg.httpPort}:9200" ];
      volumes = [
        "${cfg.configPath}:/etc/ocis"
        "${cfg.dataPath}:/var/lib/ocis"
      ];
      environmentFiles = [ ];
      environment = {
        OCIS_INSECURE = "true";
        PROXY_HTTP_ADDR = "0.0.0.0:9200";
        OCIS_URL = "https://10.0.1.3:9988";
        OCIS_ADMIN_PASSWORD = "BogieDudie1";
        OCIS_LDAP_BIND_PASSWORD = "BogieDudie1";
        PROXY_OIDC_CLIENT_SECRET = "BogieDudie1";
        IDM_ADMIN_PASSWORD = "BogieDudie1";
        PUID = cfg.puid;
        PGID = cfg.pgid;
        TZ = cfg.timeZone;
      };
    };
  };
}
