1
0
Fork 0
mirror of https://github.com/mdlayher/homelab.git synced 2024-12-14 11:47:32 +00:00

nixos/lib: temporary out-of-tree package/module for modemmanager_exporter

Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
Matt Layher 2020-07-16 13:53:30 -04:00
parent 32c7e00e6d
commit ea1b14bff8
No known key found for this signature in database
GPG key ID: 77BFE531397EDE94
4 changed files with 72 additions and 2 deletions

View file

@ -0,0 +1,41 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.modemmanager_exporter;
in {
options.services.modemmanager_exporter = {
enable = mkEnableOption "ModemManager Prometheus exporter";
package = mkOption {
default = pkgs.modemmanager_exporter;
defaultText = "pkgs.modemmanager_exporter";
type = types.package;
description = "modemmanager_exporter package to use.";
};
};
config = mkIf cfg.enable {
systemd.services.modemmanager_exporter = {
description = "ModemManager Prometheus exporter";
after = [ "network-online.target" "ModemManager.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
PermissionsStartOnly = true;
LimitNPROC = 512;
LimitNOFILE = 1048576;
NoNewPrivileges = true;
User = "modemmanager_exporter";
Group = "networkmanager";
ExecStart = "${getBin cfg.package}/bin/modemmanager_exporter";
Restart = "on-failure";
};
};
users.users.modemmanager_exporter = {
group = "networkmanager";
isSystemUser = true;
};
};
}

View file

@ -0,0 +1,24 @@
{ stdenv, buildGoModule, fetchFromGitHub }:
buildGoModule rec {
pname = "modemmanager_exporter";
version = "0.1.0";
goPackagePath = "github.com/mdlayher/modemmanager_exporter";
src = fetchFromGitHub {
owner = "mdlayher";
repo = "modemmanager_exporter";
rev = "v${version}";
sha256 = "0d8z7qzk5j5jj0ixkwpi8dw9kki78mxrajdlzzcj2rcgbnwair91";
};
modSha256 = "0vjnl6apihqb9vawspwvgqx3ckd0j66v10xc1cq6vf1nm07z76w8";
meta = with stdenv.lib; {
homepage = "github.com/mdlayher/modemmanager_exporter";
description = "Prometheus exporter for ModemManager and its devices.";
license = licenses.mit;
maintainers = with maintainers; [ mdlayher ];
};
}

View file

@ -38,6 +38,7 @@ in {
# Unstable or out-of-tree modules.
<nixos-unstable-small/nixos/modules/services/monitoring/prometheus/exporters.nix>
<nixos-unstable-small/nixos/modules/services/networking/corerad.nix>
./lib/modules/modemmanager_exporter.nix
./lib/modules/wireguard_exporter.nix
./lib/modules/wgipamd.nix
];
@ -46,6 +47,8 @@ in {
nixpkgs.overlays = [
(_self: super: {
go-toml = unstable.go-toml;
modemmanager_exporter =
super.callPackage ./lib/pkgs/modemmanager_exporter.nix { };
prometheus-apcupsd-exporter = unstable.prometheus-apcupsd-exporter;
wireguard_exporter =
super.callPackage ./lib/pkgs/wireguard_exporter.nix { };

View file

@ -129,13 +129,15 @@ in {
};
};
# Bring up MM with NM.
# Bring up MM and exporter with NM.
systemd.services.ModemManager = {
enable = true;
wantedBy = [ "NetworkManager.service" ];
};
# Enable Prometheus exporter and set up peer key/name mappings.
services.modemmanager_exporter.enable = true;
# Enable WireGuard Prometheus exporter and set up peer key/name mappings.
# TODO: nixify the configuration.
services.wireguard_exporter = {
enable = true;