blob: 3b92c05c6d5bd2ed58a5b58caf3221cc13f02cfd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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-pms7003-exporter.port;
in "0.0.0.0:${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-addr ${cfg.bind-addr} --quiet -v /dev/ttyUSB0";
};
};
};
}
|