diff --git a/pkgs/default.nix b/pkgs/default.nix index c36c7fa..4d55530 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -91,6 +91,7 @@ in { odhcp-script = callPackage ./odhcp-script {}; odhcp6c = callPackage ./odhcp6c {}; openwrt = callPackage ./openwrt {}; + openwrt-prometheus-exporter = callPackage ./openwrt-prometheus-exporter {}; ppp = callPackage ./ppp {}; pppoe = callPackage ./pppoe {}; preinit = callPackage ./preinit {}; diff --git a/pkgs/openwrt-prometheus-exporter/default.nix b/pkgs/openwrt-prometheus-exporter/default.nix new file mode 100644 index 0000000..af65185 --- /dev/null +++ b/pkgs/openwrt-prometheus-exporter/default.nix @@ -0,0 +1,60 @@ +{ + lib, + stdenv, + fetchFromGitHub, + uhttpd, + ubus, + lua, +}: +let + pkg-path = "utils/prometheus-node-exporter-lua"; +in +stdenv.mkDerivation rec { + pname = "openwrt-prometheus-exporter"; + version = "2024.06.16"; + + src = fetchFromGitHub { + owner = "openwrt"; + repo = "packages"; + rev = "openwrt-${version}"; + hash = "sha256-fPN+rgDpec86+3o9hFqgHg6eTULuXPf8jHhx5WL4udQ="; + }; + + buildInputs = [ + uhttpd + ubus + lua + ]; + + dontBuild = true; + + patchPhase = '' + runHook prePatch + + substituteInPlace ${pkg-path}/files/usr/bin/prometheus-node-exporter-lua \ + --replace-fail "/usr/lib/lua/prometheus-collectors/*.lua" "$out/lib/lua/prometheus-collectors/*.lua" + + runHook postPatch + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,lib} + + cp ${pkg-path}/files/usr/bin/prometheus-node-exporter-lua $out/bin/openwrt-prometheus-exporter + cp -r ${pkg-path}/files/usr/lib/ $out + + runHook postInstall + ''; + + + meta = { + description = "Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md"; + homepage = "https://github.com/openwrt/packages"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ soyouzpanda ]; + mainProgram = "openwrt-prometheus-exporter"; + platforms = lib.platforms.all; + }; +}