{
  lib,
  config,
  namespace,
  ...
}:
with lib;
let
  name = "nextcloud";
  cfg = config.${namespace}.services.${name};

  nextcloudConfig = lib.${namespace}.mkModule {
    inherit config name;
    serviceName = "podman-${name}";
    description = "nextcloud";
    options = { };
    moduleConfig = {
      virtualisation.oci-containers.containers."${name}" = {
        autoStart = true;
        image = "lscr.io/linuxserver/nextcloud";
        ports = [
          "${toString cfg.port}:443"
        ];
        volumes = [
          "${cfg.configDir}/nextcloud:/config"
          "${cfg.dataDir}/nextcloud:/data"
          "/run/postgresql:/run/postgresql"
        ];
        environmentFiles = [ ];
        environment = {
          PUID = cfg.puid;
          PGID = cfg.pgid;
          TZ = cfg.timeZone;
        };
      };
    };
  };
in
{
  imports = [ nextcloudConfig ];
}
