feat: init openwrt-prometheus-exporter module
All checks were successful
build liminix / build_vm_qemu_mips (pull_request) Successful in 16s
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 15s
build liminix / test_shell_customization (pull_request) Successful in 15s
build liminix / test_hostapd (pull_request) Successful in 20s

Signed-off-by: soyouzpanda <soyouzpanda@soyouzpanda.fr>
This commit is contained in:
soyouzpanda 2025-03-01 13:41:08 +01:00
parent 614dbd1c44
commit b2cb4b8d32
Signed by: ecoppens
GPG key ID: 871893E37A732093
3 changed files with 57 additions and 0 deletions

View file

@ -20,6 +20,7 @@
./mount
./network
./ntp
./openwrt-prometheus-exporter
./outputs.nix
./outputs/ext4fs.nix
./outputs/initramfs.nix

View file

@ -0,0 +1,35 @@
{ lib, pkgs, config, ... }:
let
inherit (lib) mkOption types;
inherit (pkgs) liminix;
in {
options = {
system.service.openwrt-prometheus-exporter = mkOption {
type = liminix.lib.types.serviceDefn;
};
};
config = {
system.service.openwrt-prometheus-exporter = liminix.callService ./service.nix {
package = mkOption {
type = types.package;
default = pkgs.openwrt-prometheus-exporter;
};
uhttpdPackage = mkOption {
type = types.package;
default = pkgs.uhttpd;
};
httpPorts = mkOption {
type = types.listOf types.port;
default = [ ];
};
httpsPorts = mkOption {
type = types.listOf types.port;
default = [ ];
};
};
};
}

View file

@ -0,0 +1,21 @@
{
liminix,
writeText,
lib,
}:
{ package, uhttpdPackage, httpPorts, httpsPorts }:
let
inherit (liminix.services) longrun;
makeLuaPath = lua: pkg: "${lua.pkgs.${pkg}}/share/lua/${lua.version}";
luaPath = lib.concatStringsSep ";" (map (makeLuaPath uhttpdPackage.passthru.luaPackage) [ "luasocket" ]);
in longrun {
name = "openwrt-prometheus-exporter";
run = ''
export LD_LIBRARY_PATH=${uhttpdPackage}/lib/:$LD_LIBRARY_PATH
export LUA_PATH="$LUA_PATH;${luaPath}"
${uhttpdPackage}/bin/uhttpd -f -c /dev/null -l / -L ${package}/bin/openwrt-prometheus-exporter \
${lib.concatStringsSep " " (lib.map (port: "-p ${toString port}") httpPorts)} \
${lib.concatStringsSep " " (lib.map (port: "-s ${toString port}") httpsPorts)}
'';
}