{ config, lib, ... }:

with lib;

let
  cfg = config.settings.containers.jellyfin;
in {
  options = {
    settings.containers.jellyfin.enable = lib.mkOption {
      type = lib.types.bool;
      default = false;
      description = ''
        Enable jellyfin container
      '';
    };
  };

  config = mkIf cfg.enable {
    services.podman.containers.jellyfin = {
      image = "jellyfin/jellyfin";
      network = "proxy";
      volumes = [
        "%h/containers/jellyfin/config:/config" 
        "%h/containers/jellyfin/cache:/cache" 
        "%h/media:/media"
      ];
      userNS = "keep-id";
    };

    settings.containers.caddy.routes.tbmrs-local.routes.jellyfin = {
      host = "stream";
      url = "jellyfin:8096";
    };
  };
}
