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