This commit is contained in:
Robin Appelman 2025-06-02 21:34:58 +02:00
commit dfb6dd0b57
3 changed files with 44 additions and 45 deletions

View file

@ -10,19 +10,20 @@
inputs.flakelight.follows = "flakelight";
};
};
outputs = { mill-scale, ... }: mill-scale ./. {
outputs = {mill-scale, ...}:
mill-scale ./. {
packages.wifi-prometheus-exporter = import ./package.nix;
nixosModules = { outputs, ... }: {
default =
{ pkgs
, config
, lib
, ...
nixosModules = {outputs, ...}: {
default = {
pkgs,
config,
lib,
...
}: {
imports = [ ./module.nix ];
imports = [./module.nix];
config = {
nixpkgs.overlays = [ outputs.overlays.default ];
nixpkgs.overlays = [outputs.overlays.default];
services.prometheus.exporters.wifi.package = lib.mkDefault pkgs.wifi-prometheus-exporter;
};
};

View file

@ -1,11 +1,12 @@
{ config
, lib
, pkgs
, ...
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.prometheus.exporters.wifi;
format = pkgs.formats.toml { };
format = pkgs.formats.toml {};
configFile = format.generate "wifi-prometheus-exporter-config.toml" {
ssh = {
inherit (cfg.ssh) address user;
@ -20,9 +21,7 @@ with lib; let
password_file = "$CREDENTIALS_DIRECTORY/mqtt_password";
};
};
in
{
in {
options.services.prometheus.exporters.wifi = {
enable = mkEnableOption "WiFi prometheus exporter";
@ -99,7 +98,7 @@ in
config = mkIf cfg.enable {
systemd.services."wifi-prometheus-exporter" = {
wantedBy = [ "multi-user.target" ];
wantedBy = ["multi-user.target"];
environment = {
RUST_LOG = cfg.log;
};
@ -133,9 +132,9 @@ in
RestrictAddressFamilies = "AF_INET AF_INET6";
RestrictRealtime = true;
ProtectProc = "noaccess";
SystemCallFilter = [ "@system-service" "~@resources" "~@privileged" ];
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
IPAddressDeny = "any";
IPAddressAllow = [ "192.168.0.0/16" "localhost" ];
IPAddressAllow = ["192.168.0.0/16" "localhost"];
PrivateUsers = true;
ProcSubset = "pid";
};

View file

@ -1,14 +1,13 @@
{ rustPlatform
, openssl
, pkg-config
, lib
,
}:
let
{
rustPlatform,
openssl,
pkg-config,
lib,
}: let
inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. [ "Cargo.*" "(src)(/.*)?" ];
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
in
rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage rec {
pname = "wifi-prometheus-exporter";
version = "0.1.0";
@ -27,4 +26,4 @@ rustPlatform.buildRustPackage rec {
cargoLock = {
lockFile = ./Cargo.lock;
};
}
}