mirror of
https://codeberg.org/icewind/wifi-prometheus-exporter.git
synced 2026-06-03 16:44:11 +02:00
fmt
This commit is contained in:
parent
a531df8b3f
commit
dfb6dd0b57
3 changed files with 44 additions and 45 deletions
23
flake.nix
23
flake.nix
|
|
@ -10,22 +10,23 @@
|
||||||
inputs.flakelight.follows = "flakelight";
|
inputs.flakelight.follows = "flakelight";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = { mill-scale, ... }: mill-scale ./. {
|
outputs = {mill-scale, ...}:
|
||||||
packages.wifi-prometheus-exporter = import ./package.nix;
|
mill-scale ./. {
|
||||||
|
packages.wifi-prometheus-exporter = import ./package.nix;
|
||||||
|
|
||||||
nixosModules = { outputs, ... }: {
|
nixosModules = {outputs, ...}: {
|
||||||
default =
|
default = {
|
||||||
{ pkgs
|
pkgs,
|
||||||
, config
|
config,
|
||||||
, lib
|
lib,
|
||||||
, ...
|
...
|
||||||
}: {
|
}: {
|
||||||
imports = [ ./module.nix ];
|
imports = [./module.nix];
|
||||||
config = {
|
config = {
|
||||||
nixpkgs.overlays = [ outputs.overlays.default ];
|
nixpkgs.overlays = [outputs.overlays.default];
|
||||||
services.prometheus.exporters.wifi.package = lib.mkDefault pkgs.wifi-prometheus-exporter;
|
services.prometheus.exporters.wifi.package = lib.mkDefault pkgs.wifi-prometheus-exporter;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
module.nix
21
module.nix
|
|
@ -1,11 +1,12 @@
|
||||||
{ config
|
{
|
||||||
, lib
|
config,
|
||||||
, pkgs
|
lib,
|
||||||
, ...
|
pkgs,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.services.prometheus.exporters.wifi;
|
cfg = config.services.prometheus.exporters.wifi;
|
||||||
format = pkgs.formats.toml { };
|
format = pkgs.formats.toml {};
|
||||||
configFile = format.generate "wifi-prometheus-exporter-config.toml" {
|
configFile = format.generate "wifi-prometheus-exporter-config.toml" {
|
||||||
ssh = {
|
ssh = {
|
||||||
inherit (cfg.ssh) address user;
|
inherit (cfg.ssh) address user;
|
||||||
|
|
@ -20,9 +21,7 @@ with lib; let
|
||||||
password_file = "$CREDENTIALS_DIRECTORY/mqtt_password";
|
password_file = "$CREDENTIALS_DIRECTORY/mqtt_password";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
in {
|
||||||
in
|
|
||||||
{
|
|
||||||
options.services.prometheus.exporters.wifi = {
|
options.services.prometheus.exporters.wifi = {
|
||||||
enable = mkEnableOption "WiFi prometheus exporter";
|
enable = mkEnableOption "WiFi prometheus exporter";
|
||||||
|
|
||||||
|
|
@ -99,7 +98,7 @@ in
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
systemd.services."wifi-prometheus-exporter" = {
|
systemd.services."wifi-prometheus-exporter" = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = ["multi-user.target"];
|
||||||
environment = {
|
environment = {
|
||||||
RUST_LOG = cfg.log;
|
RUST_LOG = cfg.log;
|
||||||
};
|
};
|
||||||
|
|
@ -133,9 +132,9 @@ in
|
||||||
RestrictAddressFamilies = "AF_INET AF_INET6";
|
RestrictAddressFamilies = "AF_INET AF_INET6";
|
||||||
RestrictRealtime = true;
|
RestrictRealtime = true;
|
||||||
ProtectProc = "noaccess";
|
ProtectProc = "noaccess";
|
||||||
SystemCallFilter = [ "@system-service" "~@resources" "~@privileged" ];
|
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
|
||||||
IPAddressDeny = "any";
|
IPAddressDeny = "any";
|
||||||
IPAddressAllow = [ "192.168.0.0/16" "localhost" ];
|
IPAddressAllow = ["192.168.0.0/16" "localhost"];
|
||||||
PrivateUsers = true;
|
PrivateUsers = true;
|
||||||
ProcSubset = "pid";
|
ProcSubset = "pid";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
45
package.nix
45
package.nix
|
|
@ -1,30 +1,29 @@
|
||||||
{ rustPlatform
|
{
|
||||||
, openssl
|
rustPlatform,
|
||||||
, pkg-config
|
openssl,
|
||||||
, lib
|
pkg-config,
|
||||||
,
|
lib,
|
||||||
}:
|
}: let
|
||||||
let
|
|
||||||
inherit (lib.sources) sourceByRegex;
|
inherit (lib.sources) sourceByRegex;
|
||||||
src = sourceByRegex ./. [ "Cargo.*" "(src)(/.*)?" ];
|
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
pname = "wifi-prometheus-exporter";
|
pname = "wifi-prometheus-exporter";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
|
||||||
inherit src;
|
inherit src;
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
openssl
|
openssl
|
||||||
];
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
pkg-config
|
pkg-config
|
||||||
];
|
];
|
||||||
|
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ./Cargo.lock;
|
lockFile = ./Cargo.lock;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue