diff --git a/flake.nix b/flake.nix index 5027e26..4a8cca7 100644 --- a/flake.nix +++ b/flake.nix @@ -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 { }; @@ -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; @@ -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; diff --git a/modules/inch-exporter.nix b/modules/inch-exporter.nix new file mode 100644 index 0000000..b4639bb --- /dev/null +++ b/modules/inch-exporter.nix @@ -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}"; + }; + }; + }; +} diff --git a/pkgs/inch-exporter/default.nix b/pkgs/inch-exporter/default.nix new file mode 100644 index 0000000..ee5bf36 --- /dev/null +++ b/pkgs/inch-exporter/default.nix @@ -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; + }; +} + diff --git a/pkgs/modbus-exporter/default.nix b/pkgs/modbus-exporter/default.nix new file mode 100644 index 0000000..2fc35d1 --- /dev/null +++ b/pkgs/modbus-exporter/default.nix @@ -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; + }; +} +