{
  config,
  lib,
  ...
}:
let
  cfg = config.bagel.monitoring.exporters.cadvisor;
  inherit (lib) mkEnableOption mkIf;
in
{
  options.bagel.monitoring.exporters.cadvisor.enable = (mkEnableOption "Standard cAdvisor") // { default = !config.boot.isContainer; };

  config = mkIf cfg.enable {
    services.cadvisor = {
      enable = true;
      port = 9102;
      listenAddress = "0.0.0.0";
    };

    bagel.monitoring.grafana-agent.exporters.cadvisor.port = 9102;
  };
}