feat: init openwrt-prometheus-exporter module
All checks were successful
build liminix / test_shell_customization (pull_request) Successful in 15s
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 20s
build liminix / build_vm_qemu_mips (pull_request) Successful in 20s
build liminix / test_hostapd (pull_request) Successful in 20s
All checks were successful
build liminix / test_shell_customization (pull_request) Successful in 15s
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 20s
build liminix / build_vm_qemu_mips (pull_request) Successful in 20s
build liminix / test_hostapd (pull_request) Successful in 20s
Signed-off-by: soyouzpanda <soyouzpanda@soyouzpanda.fr>
This commit is contained in:
parent
614dbd1c44
commit
1f00586428
3 changed files with 59 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
||||||
./mount
|
./mount
|
||||||
./network
|
./network
|
||||||
./ntp
|
./ntp
|
||||||
|
./openwrt-prometheus-exporter
|
||||||
./outputs.nix
|
./outputs.nix
|
||||||
./outputs/ext4fs.nix
|
./outputs/ext4fs.nix
|
||||||
./outputs/initramfs.nix
|
./outputs/initramfs.nix
|
||||||
|
|
35
modules/openwrt-prometheus-exporter/default.nix
Normal file
35
modules/openwrt-prometheus-exporter/default.nix
Normal 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 = [ ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
23
modules/openwrt-prometheus-exporter/service.nix
Normal file
23
modules/openwrt-prometheus-exporter/service.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
liminix,
|
||||||
|
writeText,
|
||||||
|
lib,
|
||||||
|
}:
|
||||||
|
{ package, uhttpdPackage, httpPorts, httpsPorts }:
|
||||||
|
let
|
||||||
|
inherit (liminix.services) longrun;
|
||||||
|
luaEnv = uhttpdPackage.passthru.luaPackage.withPackages (ps: [
|
||||||
|
ps.luasocket
|
||||||
|
]);
|
||||||
|
luaPath = luaEnv.luaPath;
|
||||||
|
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)}
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue