{ 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"; }; }; }; }