Skip to content

Commit

Permalink
Add modbus-exporter and inch-exporter
Browse files Browse the repository at this point in the history
In the end inch-exporter is more powerful in transforming the modbus
information from the inch carcharger.
  • Loading branch information
simonswine committed Jan 1, 2025
1 parent bd22753 commit 454a848
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
goda = pkgs.callPackage ./pkgs/goda { };
growatt-proxy-exporter = pkgs.callPackage ./pkgs/growatt-proxy-exporter { };
heatmiser-exporter = pkgs.callPackage ./pkgs/heatmiser-exporter { };
inch-exporter = pkgs.callPackage ./pkgs/inch-exporter { };
intel-gpu-exporter = pkgs.callPackage ./pkgs/intel-gpu-exporter { };
jsonnet-language-server = pkgs.callPackage ./pkgs/jsonnet-language-server { };
mi-flora-exporter = pkgs.callPackage ./pkgs/mi-flora-exporter { };
miio = pkgs.callPackage ./pkgs/python-miio { };
modbus-exporter = pkgs.callPackage ./pkgs/modbus-exporter { };
modularise = pkgs.callPackage ./pkgs/modularise { };
mtv-dl = pkgs.callPackage ./pkgs/mtv-dl { };
nut-exporter = pkgs.callPackage ./pkgs/nut-exporter { };
Expand Down Expand Up @@ -169,6 +171,7 @@
goda = pkgs.goda;
growatt-proxy-exporter = pkgs.growatt-proxy-exporter;
heatmiser-exporter = pkgs.heatmiser-exporter;
inch-exporter = pkgs.inch-exporter;
intel-gpu-exporter = pkgs.intel-gpu-exporter;
jsonnet-language-server = pkgs.jsonnet-language-server;
kubernetes-1-28 = pkgs.kubernetes-1-28;
Expand All @@ -177,6 +180,7 @@
kubernetes-1-31 = pkgs.kubernetes-1-31;
mi-flora-exporter = pkgs.mi-flora-exporter;
miio = pkgs.miio;
modbus-exporter = pkgs.modbus-exporter;
modularise = pkgs.modularise;
mtv-dl = pkgs.mtv-dl;
nut-exporter = pkgs.nut-exporter;
Expand Down
33 changes: 33 additions & 0 deletions modules/inch-exporter.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ config, pkgs, lib, ... }:
let
cfg = config.services.inch-exporter;
in
with lib;

{
options.services.inch-exporter = {
enable = mkEnableOption "inch-exporter";

listenAddress = mkOption {
default = "127.0.0.1:9111";
type = types.str;
};

inchUrl = mkOption {
type = types.str;
};

};

config = mkIf cfg.enable {
systemd.services.inch-exporter = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
DynamicUser = true;
EnvironmentFile = "-/etc/sysconfig/inch-exporter";
ExecStart = "${pkgs.inch-exporter}/bin/inch-exporter -listen-address ${cfg.listenAddress} -inch-url ${cfg.inchUrl}";
};
};
};
}
25 changes: 25 additions & 0 deletions pkgs/inch-exporter/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
pname = "inch-exporter";
version = "0.1.0";

src = fetchFromGitHub {
owner = "simonswine";
repo = "inch-exporter";
rev = "v${version}";
hash = "sha256-1Xl8ukEKnZuzKsvhRfvO1b3B4knSb31znUsOk1CjkXM=";
};

vendorHash = "sha256-ws321AvIOMFyxt7L+l5RcHw38G+84aquSvB+3GSM4pE=";

subPackages = [ "." ];

meta = with lib; {
homepage = "https://github.com/simonswine/inch-exporter";
license = licenses.asl20;
maintainers = with maintainers; [ simonswine ];
platforms = platforms.unix;
};
}

29 changes: 29 additions & 0 deletions pkgs/modbus-exporter/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
pname = "modbus-exporter";
version = "0.4.1";

src = fetchFromGitHub {
owner = "RichiH";
repo = "modbus_exporter";
rev = "v${version}";
hash = "sha256-ZkES+CDthYZrNZ7wVO0oRx6pBMX23AyUOhU+OBTD42g=";
};

vendorHash = "sha256-RfpJLoYPR5Ura3GvLIAePg+fuiaiXig6XaSNCPhZ/Vg=";

subPackages = [ "." ];

postInstall = ''
mv $out/bin/modbus_exporter $out/bin/modbus-exporter
'';

meta = with lib; {
homepage = "https://github.com/simonswine/modbus-exporter";
license = licenses.asl20;
maintainers = with maintainers; [ simonswine ];
platforms = platforms.unix;
};
}

0 comments on commit 454a848

Please sign in to comment.