From 4801b0f626e6f393e7c865b084e7b80a518ada96 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Fri, 12 Nov 2021 17:55:06 -0500 Subject: Create static IP mapping for firelink --- modules/pms7003-exporter.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 modules/pms7003-exporter.nix (limited to 'modules') diff --git a/modules/pms7003-exporter.nix b/modules/pms7003-exporter.nix new file mode 100644 index 0000000..cc27e4c --- /dev/null +++ b/modules/pms7003-exporter.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.orbekk.pms7003-exporter; + aliases = import ../data/aliases.nix; +in +{ + options = { + orbekk.pms7003-exporter = { + enable = lib.mkEnableOption "Enable PMS7003 exporter"; + bind-addr = lib.mkOption { + type = lib.types.str; + default = let + port = aliases.services.prometheus-snmp-exporter.port; + in "127.0.0.1:${toString port}"; + }; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.services.pms7003-exporter = { + description = "PMS7003 prometheus exporter"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + DynamicUser = true; + SupplementaryGroups = "dialout"; + ExecStart = "${pkgs.pms7003}/bin/pms7003 --prometheus-bind-address ${cfg.bind-addr} --quiet -v"; + }; + }; + }; +} -- cgit v1.2.3