summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2023-05-08 20:15:17 -0400
committerGitHub <noreply@github.com>2023-05-08 20:15:17 -0400
commitcf0327810b63f88ed8b2f3fdcdcf8e60e58b7b85 (patch)
treea7dbce620f1fb7be8330b6970668ba61a116417b /nixos
parent8fe90f598663a14282d03f8410b172458280a1fb (diff)
parent060f0dd496b10c5516de48977f268505a51ab116 (diff)
downloadnixpkgs-cf0327810b63f88ed8b2f3fdcdcf8e60e58b7b85.tar
nixpkgs-cf0327810b63f88ed8b2f3fdcdcf8e60e58b7b85.tar.gz
nixpkgs-cf0327810b63f88ed8b2f3fdcdcf8e60e58b7b85.tar.bz2
nixpkgs-cf0327810b63f88ed8b2f3fdcdcf8e60e58b7b85.tar.lz
nixpkgs-cf0327810b63f88ed8b2f3fdcdcf8e60e58b7b85.tar.xz
nixpkgs-cf0327810b63f88ed8b2f3fdcdcf8e60e58b7b85.tar.zst
nixpkgs-cf0327810b63f88ed8b2f3fdcdcf8e60e58b7b85.zip
Merge pull request #207093 from ymarkus/alertmanager
nixos/alertmanager: add checkConfig option
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/prometheus/alertmanager.nix24
1 files changed, 20 insertions, 4 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/alertmanager.nix b/nixos/modules/services/monitoring/prometheus/alertmanager.nix
index 0c0931d3d29..987f17c2c6e 100644
--- a/nixos/modules/services/monitoring/prometheus/alertmanager.nix
+++ b/nixos/modules/services/monitoring/prometheus/alertmanager.nix
@@ -6,10 +6,12 @@ let
   cfg = config.services.prometheus.alertmanager;
   mkConfigFile = pkgs.writeText "alertmanager.yml" (builtins.toJSON cfg.configuration);
 
-  checkedConfig = file: pkgs.runCommand "checked-config" { buildInputs = [ cfg.package ]; } ''
-    ln -s ${file} $out
-    amtool check-config $out
-  '';
+  checkedConfig = file:
+    if cfg.checkConfig then
+      pkgs.runCommand "checked-config" { buildInputs = [ cfg.package ]; } ''
+        ln -s ${file} $out
+        amtool check-config $out
+      '' else file;
 
   alertmanagerYml = let
     yml = if cfg.configText != null then
@@ -70,6 +72,20 @@ in {
         '';
       };
 
+      checkConfig = mkOption {
+        type = types.bool;
+        default = true;
+        description = lib.mdDoc ''
+          Check configuration with `amtool check-config`. The call to `amtool` is
+          subject to sandboxing by Nix.
+
+          If you use credentials stored in external files
+          (`environmentFile`, etc),
+          they will not be visible to `amtool`
+          and it will report errors, despite a correct configuration.
+        '';
+      };
+
       logFormat = mkOption {
         type = types.nullOr types.str;
         default = null;