at 21.11-pre 1.6 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.grafana_reporter; 7 8in { 9 options.services.grafana_reporter = { 10 enable = mkEnableOption "grafana_reporter"; 11 12 grafana = { 13 protocol = mkOption { 14 description = "Grafana protocol."; 15 default = "http"; 16 type = types.enum ["http" "https"]; 17 }; 18 addr = mkOption { 19 description = "Grafana address."; 20 default = "127.0.0.1"; 21 type = types.str; 22 }; 23 port = mkOption { 24 description = "Grafana port."; 25 default = 3000; 26 type = types.int; 27 }; 28 29 }; 30 addr = mkOption { 31 description = "Listening address."; 32 default = "127.0.0.1"; 33 type = types.str; 34 }; 35 36 port = mkOption { 37 description = "Listening port."; 38 default = 8686; 39 type = types.int; 40 }; 41 42 templateDir = mkOption { 43 description = "Optional template directory to use custom tex templates"; 44 default = "${pkgs.grafana_reporter}"; 45 type = types.str; 46 }; 47 }; 48 49 config = mkIf cfg.enable { 50 systemd.services.grafana_reporter = { 51 description = "Grafana Reporter Service Daemon"; 52 wantedBy = ["multi-user.target"]; 53 after = ["network.target"]; 54 serviceConfig = let 55 args = lib.concatStringsSep " " [ 56 "-proto ${cfg.grafana.protocol}://" 57 "-ip ${cfg.grafana.addr}:${toString cfg.grafana.port}" 58 "-port :${toString cfg.port}" 59 "-templates ${cfg.templateDir}" 60 ]; 61 in { 62 ExecStart = "${pkgs.grafana_reporter}/bin/grafana-reporter ${args}"; 63 }; 64 }; 65 }; 66}