diff options
Diffstat (limited to 'nixos/modules/services/logging/promtail.nix')
-rw-r--r-- | nixos/modules/services/logging/promtail.nix | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/nixos/modules/services/logging/promtail.nix b/nixos/modules/services/logging/promtail.nix index 9eccd34cef23..d6038055c05c 100644 --- a/nixos/modules/services/logging/promtail.nix +++ b/nixos/modules/services/logging/promtail.nix @@ -10,15 +10,29 @@ let allowPositionsFile = !lib.hasPrefix "/var/cache/promtail" positionsFile; positionsFile = cfg.configuration.positions.filename; + + configFile = if cfg.configFile != null + then cfg.configFile + else prettyJSON cfg.configuration; + in { options.services.promtail = with types; { enable = mkEnableOption "the Promtail ingresser"; - configuration = mkOption { type = (pkgs.formats.json {}).type; description = '' Specify the configuration for Promtail in Nix. + This option will be ignored if `services.promtail.configFile` is defined. + ''; + }; + + configFile = mkOption { + type = nullOr path; + default = null; + description = '' + Config file path for Promtail. + If this option is defined, the value of `services.promtail.configuration` will be ignored. ''; }; @@ -42,14 +56,14 @@ in { stopIfChanged = false; preStart = '' - ${lib.getExe pkgs.promtail} -config.file=${prettyJSON cfg.configuration} -check-syntax + ${lib.getExe pkgs.promtail} -config.file=${configFile} -check-syntax ''; serviceConfig = { Restart = "on-failure"; TimeoutStopSec = 10; - ExecStart = "${pkgs.promtail}/bin/promtail -config.file=${prettyJSON cfg.configuration} ${escapeShellArgs cfg.extraFlags}"; + ExecStart = "${pkgs.promtail}/bin/promtail -config.file=${configFile} ${escapeShellArgs cfg.extraFlags}"; ProtectSystem = "strict"; ProtectHome = true; @@ -80,7 +94,7 @@ in { PrivateUsers = true; SupplementaryGroups = lib.optional (allowSystemdJournal) "systemd-journal"; - } // (optionalAttrs (!pkgs.stdenv.isAarch64) { # FIXME: figure out why this breaks on aarch64 + } // (optionalAttrs (!pkgs.stdenv.hostPlatform.isAarch64) { # FIXME: figure out why this breaks on aarch64 SystemCallFilter = "@system-service"; }); }; |