nixos/telegraf: allow multiple env files
This commit is contained in:
parent
8edc4619ab
commit
7534d92648
@ -20,9 +20,9 @@ in {
|
||||
type = types.package;
|
||||
};
|
||||
|
||||
environmentFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
environmentFiles = mkOption {
|
||||
type = types.nullOr (types.listOf types.path);
|
||||
default = [];
|
||||
example = "/run/keys/telegraf.env";
|
||||
description = ''
|
||||
File to load as environment file. Environment variables
|
||||
@ -59,7 +59,7 @@ in {
|
||||
###### implementation
|
||||
config = mkIf config.services.telegraf.enable {
|
||||
systemd.services.telegraf = let
|
||||
finalConfigFile = if config.services.telegraf.environmentFile == null
|
||||
finalConfigFile = if config.services.telegraf.environmentFiles == []
|
||||
then configFile
|
||||
else "/var/run/telegraf/config.toml";
|
||||
in {
|
||||
@ -67,8 +67,8 @@ in {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
serviceConfig = {
|
||||
EnvironmentFile = config.services.telegraf.environmentFile;
|
||||
ExecStartPre = lib.optional (config.services.telegraf.environmentFile != null)
|
||||
EnvironmentFile = config.services.telegraf.environmentFiles;
|
||||
ExecStartPre = lib.optional (config.services.telegraf.environmentFiles != [])
|
||||
(pkgs.writeShellScript "pre-start" ''
|
||||
umask 077
|
||||
${pkgs.envsubst}/bin/envsubst -i "${configFile}" > /var/run/telegraf/config.toml
|
||||
|
@ -6,9 +6,9 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
|
||||
machine = { ... }: {
|
||||
services.telegraf.enable = true;
|
||||
services.telegraf.environmentFile = pkgs.writeText "secrets" ''
|
||||
services.telegraf.environmentFiles = [pkgs.writeText "secrets" ''
|
||||
SECRET=example
|
||||
'';
|
||||
''];
|
||||
services.telegraf.extraConfig = {
|
||||
agent.interval = "1s";
|
||||
agent.flush_interval = "1s";
|
||||
|
Loading…
Reference in New Issue
Block a user