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
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:
parent
614dbd1c44
commit
b2cb4b8d32
3 changed files with 57 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
./mount
|
||||
./network
|
||||
./ntp
|
||||
./openwrt-prometheus-exporter
|
||||
./outputs.nix
|
||||
./outputs/ext4fs.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 = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
21
modules/openwrt-prometheus-exporter/service.nix
Normal file
21
modules/openwrt-prometheus-exporter/service.nix
Normal 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)}
|
||||
'';
|
||||
}
|
Loading…
Add table
Reference in a new issue