Unverified Commit f73e3140 authored by Ramses's avatar Ramses Committed by GitHub
Browse files

prometheus-klipper-exporter: init at v0.11.2 (#348187)

parents fa5b7f30 e13a31e4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ let
    "junos-czerwonk"
    "kea"
    "keylight"
    "klipper"
    "knot"
    "lnd"
    "mail"
+55 −0
Original line number Diff line number Diff line
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.services.prometheus.exporters.klipper;
  inherit (lib)
    mkOption
    mkMerge
    mkIf
    types
    concatStringsSep
    any
    optionalString
    ;
  moonraker = config.services.moonraker;
in
{
  port = 9101;
  extraOpts = {
    package = lib.mkPackageOption pkgs "prometheus-klipper-exporter" { };

    moonrakerApiKey = mkOption {
      type = types.str;
      default = "";
      description = ''
        API Key to authenticate with the Moonraker APIs.
        Only needed if the host running the exporter is not a trusted client to Moonraker.
      '';
    };
  };
  serviceOpts = mkMerge (
    [
      {
        serviceConfig = {
          ExecStart = concatStringsSep " " [
            "${cfg.package}/bin/prometheus-klipper-exporter"
            (optionalString (cfg.moonrakerApiKey != "") "--moonraker.apikey ${cfg.moonrakerApiKey}")
            "--web.listen-address ${cfg.listenAddress}:${toString cfg.port}"
            "${concatStringsSep " " cfg.extraFlags}"
          ];
        };
      }
    ]
    ++ [
      (mkIf config.services.moonraker.enable {
        after = [ "moonraker.service" ];
        requires = [ "moonraker.service" ];
      })
    ]
  );
}
+34 −0
Original line number Diff line number Diff line
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  nixosTests,
}:

buildGoModule rec {
  pname = "prometheus-klipper-exporter";
  version = "0.11.2";

  src = fetchFromGitHub {
    owner = "scross01";
    repo = "prometheus-klipper-exporter";
    rev = "v${version}";
    sha256 = "sha256-ow7bzgaY4pYccslITlkNBKfZBJv9uwPk25I1Y3bnjbU=";
  };

  vendorHash = "sha256-0nbLHZ2WMLMK0zKZuUYz355K01Xspn9svmlFCtQjed0=";

  doCheck = true;

  passthru.tests = {
    inherit (nixosTests.prometheus-exporters) process;
  };

  meta = with lib; {
    description = " Prometheus Exporter for Klipper ";
    homepage = "https://github.com/scross01/prometheus-klipper-exporter";
    license = licenses.mit;
    maintainers = with maintainers; [ wulfsta ];
    platforms = platforms.linux;
  };
}