{
  lib,
  config,
  namespace,
  ...
}:
with lib;
let
  cfg = config.${namespace}.services.mongodb;
in
{
  imports = [ ./options.nix ];

  config = mkIf cfg.enable {
    virtualisation.oci-containers.containers."${cfg.name}" = {
      autoStart = cfg.autoStart;
      image = cfg.image;
      ports = [ "${cfg.port}:27017" ];
      volumes = [ "${cfg.configPath}:/data/db" ];
      extraOptions = [ "--network-alias=mongo" ];
      # environmentFiles = cfg.environmentFiles;
      environment = {
        PUID = cfg.puid;
        PGID = cfg.pgid;
        TZ = cfg.timeZone;
        # MONGO_INITDB_ROOT_USERNAME = "";#cfg.databaseUser;
        # MONGO_INITDB_ROOT_PASSWORD = "";#cfg.databasePassword; # get from env file
      };
    };
  };
}
