diff options
Diffstat (limited to 'nixos/shared/prometheus-sql-exporter/service.nix')
-rw-r--r-- | nixos/shared/prometheus-sql-exporter/service.nix | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/nixos/shared/prometheus-sql-exporter/service.nix b/nixos/shared/prometheus-sql-exporter/service.nix new file mode 100644 index 0000000..a887f91 --- /dev/null +++ b/nixos/shared/prometheus-sql-exporter/service.nix @@ -0,0 +1,30 @@ +# TODO: submit burningalchemist's sql_exporter to nixpkgs +{ config, lib, pkgs, ... }: + +let + sqlExporter = pkgs.callPackage ./default.nix {}; + cfg = config.services.prometheus-sql-exporter; + configFile = builtins.toFile "config.yaml" (builtins.toJSON cfg.config); +in +{ + options.services.prometheus-sql-exporter = { + enable = lib.mkEnableOption "sql-exporter"; + port = lib.mkOption { + type = lib.types.int; + }; + config = lib.mkOption { + type = (pkgs.formats.json {}).type; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.services.prometheus-sql-exporter = { + serviceConfig = { + ExecStart = "${sqlExporter}/bin/sql_exporter -config.file ${configFile} -web.listen-address :${toString cfg.port}"; + DynamicUser = "true"; + User = "prometheus-sql-exporter"; + }; + wantedBy = ["multi-user.target"]; + }; + }; +} |