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

  dispatcharrConfig = lib.${namespace}.mkModule {
    inherit config name;
    serviceName = "podman-${name}";
    description = "dispatcharr podman container";
    options = { };
    moduleConfig = {
      virtualisation.oci-containers.containers.${name} = {
        autoStart = true;
        image = "ghcr.io/dispatcharr/dispatcharr";
        extraOptions = [ "--device=/dev/dri" ];
        volumes = [
          "${cfg.configDir}/dispatcharr:/data"
          "${cfg.dataDir}/movies:/movies"
          "${cfg.dataDir}/tv:/tv"
        ];
        ports = [
          "${toString cfg.port}:9191"
        ];
        environment = {
          DISPATCHARR_LOG_LEVEL = "DEBUG";
          DISPATCHARR_ENV = "aio";
          DJANGO_SECRET_KEY = "123456";
          PUID = cfg.puid;
          PGID = cfg.pgid;
          TZ = cfg.timeZone;
        };
      };
    };
  };
in
{
  imports = [ dispatcharrConfig ];
}
