Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7c08ba312b0b
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 342bc51089ac
Choose a head ref
  • 3 commits
  • 1 file changed
  • 2 contributors

Commits on Jan 23, 2020

  1. Copy the full SHA
    23d5d9b View commit details

Commits on Jan 24, 2020

  1. Copy the full SHA
    ed6e4a9 View commit details
  2. Merge pull request #78358 from serokell/yorickvp/alertmanager-secret

    nixos/alertmanager: add environmentFile, envsubst for secrets
    infinisil authored Jan 24, 2020
    Copy the full SHA
    342bc51 View commit details
Showing with 19 additions and 2 deletions.
  1. +19 −2 nixos/modules/services/monitoring/prometheus/alertmanager.nix
21 changes: 19 additions & 2 deletions nixos/modules/services/monitoring/prometheus/alertmanager.nix
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ let
in checkedConfig yml;

cmdlineArgs = cfg.extraFlags ++ [
"--config.file ${alertmanagerYml}"
"--config.file /tmp/alert-manager-substituted.yaml"
"--web.listen-address ${cfg.listenAddress}:${toString cfg.port}"
"--log.level ${cfg.logLevel}"
] ++ (optional (cfg.webExternalUrl != null)
@@ -127,6 +127,18 @@ in {
Extra commandline options when launching the Alertmanager.
'';
};

environmentFile = mkOption {
type = types.nullOr types.path;
default = null;
example = "/root/alertmanager.env";
description = ''
File to load as environment file. Environment variables
from this file will be interpolated into the config file
using envsubst with this syntax:
<literal>$ENVIRONMENT ''${VARIABLE}</literal>
'';
};
};
};

@@ -144,9 +156,14 @@ in {
systemd.services.alertmanager = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
preStart = ''
${lib.getBin pkgs.envsubst}/bin/envsubst -o /tmp/alert-manager-substituted.yaml" \
-i ${alertmanagerYml}"
'';
serviceConfig = {
Restart = "always";
DynamicUser = true;
DynamicUser = true; # implies PrivateTmp
EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
WorkingDirectory = "/tmp";
ExecStart = "${cfg.package}/bin/alertmanager" +
optionalString (length cmdlineArgs != 0) (" \\\n " +