feat: init openwrt-prometheus-exporter module
All checks were successful
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 16s
build liminix / build_vm_qemu_mips (pull_request) Successful in 16s
build liminix / test_hostapd (pull_request) Successful in 16s
build liminix / test_shell_customization (pull_request) Successful in 16s
All checks were successful
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 16s
build liminix / build_vm_qemu_mips (pull_request) Successful in 16s
build liminix / test_hostapd (pull_request) Successful in 16s
build liminix / test_shell_customization (pull_request) Successful in 16s
Signed-off-by: soyouzpanda <soyouzpanda@soyouzpanda.fr>
This commit is contained in:
parent
16ec6fbf08
commit
43fbde863c
3 changed files with 64 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
./mount
|
||||
./network
|
||||
./ntp
|
||||
./openwrt-prometheus-exporter
|
||||
./outputs.nix
|
||||
./outputs/ext4fs.nix
|
||||
./outputs/initramfs.nix
|
||||
|
|
25
modules/openwrt-prometheus-exporter/default.nix
Normal file
25
modules/openwrt-prometheus-exporter/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ 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 {
|
||||
httpPorts = mkOption {
|
||||
type = types.listOf types.port;
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
httpsPorts = mkOption {
|
||||
type = types.listOf types.port;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
38
modules/openwrt-prometheus-exporter/service.nix
Normal file
38
modules/openwrt-prometheus-exporter/service.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
liminix,
|
||||
lib,
|
||||
luasocket,
|
||||
lua,
|
||||
uhttpd,
|
||||
ubus,
|
||||
openwrt-prometheus-exporter
|
||||
}:
|
||||
{ httpPorts, httpsPorts }:
|
||||
let
|
||||
inherit (liminix.services) longrun;
|
||||
|
||||
package = openwrt-prometheus-exporter;
|
||||
|
||||
luaPath = lib.concatStringsSep ";" [
|
||||
"$LUA_PATH"
|
||||
"${luasocket}/share/lua/${lua.luaversion}/?.lua"
|
||||
"${package}/share/lua/${lua.luaversion}/?.lua"
|
||||
];
|
||||
|
||||
luaCPath = lib.concatStringsSep ";" [
|
||||
"$LUA_CPATH"
|
||||
"${luasocket}/lib/lua/${lua.luaversion}/?.so"
|
||||
"${ubus}/lib/lua/${lua.luaversion}/?.so"
|
||||
];
|
||||
in longrun {
|
||||
name = "openwrt-prometheus-exporter";
|
||||
run = ''
|
||||
export LD_LIBRARY_PATH=${uhttpd}/lib/:$LD_LIBRARY_PATH
|
||||
export LUA_CPATH="${luaCPath}"
|
||||
export LUA_PATH="${luaPath}"
|
||||
|
||||
${uhttpd}/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)}
|
||||
'';
|
||||
}
|
Loading…
Add table
Reference in a new issue