From 56bd2c2da6d0d451bb1980980f26d7dac3bd1cb5 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Fri, 30 Aug 2024 00:46:59 +0200 Subject: [PATCH] nixos/services.longview: remove `with lib;` --- .../modules/services/monitoring/longview.nix | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/nixos/modules/services/monitoring/longview.nix b/nixos/modules/services/monitoring/longview.nix index aafe54b994ab..ecb4836169db 100644 --- a/nixos/modules/services/monitoring/longview.nix +++ b/nixos/modules/services/monitoring/longview.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.longview; @@ -13,16 +10,16 @@ in { services.longview = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' If enabled, system metrics will be sent to Linode LongView. ''; }; - apiKey = mkOption { - type = types.str; + apiKey = lib.mkOption { + type = lib.types.str; default = ""; example = "01234567-89AB-CDEF-0123456789ABCDEF"; description = '' @@ -34,8 +31,8 @@ in { ''; }; - apiKeyFile = mkOption { - type = types.nullOr types.path; + apiKeyFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; example = "/run/keys/longview-api-key"; description = '' @@ -47,8 +44,8 @@ in { ''; }; - apacheStatusUrl = mkOption { - type = types.str; + apacheStatusUrl = lib.mkOption { + type = lib.types.str; default = ""; example = "http://127.0.0.1/server-status"; description = '' @@ -58,8 +55,8 @@ in { ''; }; - nginxStatusUrl = mkOption { - type = types.str; + nginxStatusUrl = lib.mkOption { + type = lib.types.str; default = ""; example = "http://127.0.0.1/nginx_status"; description = '' @@ -69,8 +66,8 @@ in { ''; }; - mysqlUser = mkOption { - type = types.str; + mysqlUser = lib.mkOption { + type = lib.types.str; default = ""; description = '' The user for connecting to the MySQL database. If provided, @@ -80,8 +77,8 @@ in { ''; }; - mysqlPassword = mkOption { - type = types.str; + mysqlPassword = lib.mkOption { + type = lib.types.str; default = ""; description = '' The password corresponding to {option}`mysqlUser`. @@ -90,8 +87,8 @@ in { ''; }; - mysqlPasswordFile = mkOption { - type = types.nullOr types.path; + mysqlPasswordFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; example = "/run/keys/dbpassword"; description = '' @@ -103,7 +100,7 @@ in { }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.longview = { description = "Longview Metrics Collection"; after = [ "network.target" ]; @@ -116,27 +113,27 @@ in { preStart = '' umask 077 mkdir -p ${configsDir} - '' + (optionalString (cfg.apiKeyFile != null) '' + '' + (lib.optionalString (cfg.apiKeyFile != null) '' cp --no-preserve=all "${cfg.apiKeyFile}" ${runDir}/longview.key - '') + (optionalString (cfg.apacheStatusUrl != "") '' + '') + (lib.optionalString (cfg.apacheStatusUrl != "") '' cat > ${configsDir}/Apache.conf < ${configsDir}/MySQL.conf < ${configsDir}/Nginx.conf <