From f1019c7adb84acdbe54e9175763873c35711a28f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Fri, 30 Aug 2024 00:46:57 +0200 Subject: [PATCH] nixos/services.grafana-image-renderer: remove `with lib;` --- .../monitoring/grafana-image-renderer.nix | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/nixos/modules/services/monitoring/grafana-image-renderer.nix b/nixos/modules/services/monitoring/grafana-image-renderer.nix index e06720b15302..e477f73adaa1 100644 --- a/nixos/modules/services/monitoring/grafana-image-renderer.nix +++ b/nixos/modules/services/monitoring/grafana-image-renderer.nix @@ -1,7 +1,4 @@ { lib, pkgs, config, ... }: - -with lib; - let cfg = config.services.grafana-image-renderer; @@ -10,34 +7,34 @@ let configFile = format.generate "grafana-image-renderer-config.json" cfg.settings; in { options.services.grafana-image-renderer = { - enable = mkEnableOption "grafana-image-renderer"; + enable = lib.mkEnableOption "grafana-image-renderer"; - chromium = mkOption { - type = types.package; + chromium = lib.mkOption { + type = lib.types.package; description = '' The chromium to use for image rendering. ''; }; - verbose = mkEnableOption "verbosity for the service"; + verbose = lib.mkEnableOption "verbosity for the service"; - provisionGrafana = mkEnableOption "Grafana configuration for grafana-image-renderer"; + provisionGrafana = lib.mkEnableOption "Grafana configuration for grafana-image-renderer"; - settings = mkOption { - type = types.submodule { + settings = lib.mkOption { + type = lib.types.submodule { freeformType = format.type; options = { service = { - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 8081; description = '' The TCP port to use for the rendering server. ''; }; - logging.level = mkOption { - type = types.enum [ "error" "warning" "info" "debug" ]; + logging.level = lib.mkOption { + type = lib.types.enum [ "error" "warning" "info" "debug" ]; default = "info"; description = '' The log-level of the {file}`grafana-image-renderer.service`-unit. @@ -45,23 +42,23 @@ in { }; }; rendering = { - width = mkOption { + width = lib.mkOption { default = 1000; - type = types.ints.positive; + type = lib.types.ints.positive; description = '' Width of the PNG used to display the alerting graph. ''; }; - height = mkOption { + height = lib.mkOption { default = 500; - type = types.ints.positive; + type = lib.types.ints.positive; description = '' Height of the PNG used to display the alerting graph. ''; }; - mode = mkOption { + mode = lib.mkOption { default = "default"; - type = types.enum [ "default" "reusable" "clustered" ]; + type = lib.types.enum [ "default" "reusable" "clustered" ]; description = '' Rendering mode of `grafana-image-renderer`: @@ -74,8 +71,8 @@ in { for that mode can be declared in `rendering.clustering`. ''; }; - args = mkOption { - type = types.listOf types.str; + args = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ "--no-sandbox" ]; description = '' List of CLI flags passed to `chromium`. @@ -96,7 +93,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { assertions = [ { assertion = cfg.provisionGrafana -> config.services.grafana.enable; message = '' @@ -106,23 +103,23 @@ in { } ]; - services.grafana.settings.rendering = mkIf cfg.provisionGrafana { + services.grafana.settings.rendering = lib.mkIf cfg.provisionGrafana { server_url = "http://localhost:${toString cfg.settings.service.port}/render"; callback_url = "http://${config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}"; }; - services.grafana-image-renderer.chromium = mkDefault pkgs.chromium; + services.grafana-image-renderer.chromium = lib.mkDefault pkgs.chromium; services.grafana-image-renderer.settings = { - rendering = mapAttrs (const mkDefault) { + rendering = lib.mapAttrs (lib.const lib.mkDefault) { chromeBin = "${cfg.chromium}/bin/chromium"; verboseLogging = cfg.verbose; timezone = config.time.timeZone; }; service = { - logging.level = mkIf cfg.verbose (mkDefault "debug"); - metrics.enabled = mkDefault false; + logging.level = lib.mkIf cfg.verbose (lib.mkDefault "debug"); + metrics.enabled = lib.mkDefault false; }; }; @@ -144,5 +141,5 @@ in { }; }; - meta.maintainers = with maintainers; [ ma27 ]; + meta.maintainers = with lib.maintainers; [ ma27 ]; }