summaryrefslogtreecommitdiffstats
path: root/nixos/modules
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2020-12-02 03:30:11 -0600
committerGitHub <noreply@github.com>2020-12-02 03:30:11 -0600
commit652ac693730ff25ce2193cbd97ae46f1309ff767 (patch)
treeb61d4633cee3993afbe7ccc891f10503cd624692 /nixos/modules
parentc9ae57cdb495a3f5bc5171cea296c9e8b4d1ca56 (diff)
parent85767db6b8b30dd11191e287a6a2fe1e2275ede1 (diff)
Merge pull request #103393 from happysalada/add_vector
nixos/vector: add module
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/logging/vector.nix61
2 files changed, 62 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index f5e6c5f4d619..df8e5e1dd699 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -397,6 +397,7 @@
./services/logging/rsyslogd.nix
./services/logging/syslog-ng.nix
./services/logging/syslogd.nix
+ ./services/logging/vector.nix
./services/mail/clamsmtp.nix
./services/mail/davmail.nix
./services/mail/dkimproxy-out.nix
diff --git a/nixos/modules/services/logging/vector.nix b/nixos/modules/services/logging/vector.nix
new file mode 100644
index 000000000000..a7c54ad75fde
--- /dev/null
+++ b/nixos/modules/services/logging/vector.nix
@@ -0,0 +1,61 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let cfg = config.services.vector;
+
+in {
+ options.services.vector = {
+ enable = mkEnableOption "Vector";
+
+ journaldAccess = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Enable Vector to access journald.
+ '';
+ };
+
+ settings = mkOption {
+ type = (pkgs.formats.json { }).type;
+ default = { };
+ description = ''
+ Specify the configuration for Vector in Nix.
+ '';
+ };
+ };
+
+ config = mkIf cfg.enable {
+
+ users.groups.vector = { };
+ users.users.vector = {
+ description = "Vector service user";
+ group = "vector";
+ isSystemUser = true;
+ };
+ systemd.services.vector = {
+ description = "Vector event and log aggregator";
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network-online.target" ];
+ requires = [ "network-online.target" ];
+ serviceConfig = let
+ format = pkgs.formats.toml { };
+ conf = format.generate "vector.toml" cfg.settings;
+ validateConfig = file:
+ pkgs.runCommand "validate-vector-conf" { } ''
+ ${pkgs.vector}/bin/vector validate --no-topology --no-environment "${file}"
+ ln -s "${file}" "$out"
+ '';
+ in {
+ ExecStart = "${pkgs.vector}/bin/vector --config ${validateConfig conf}";
+ User = "vector";
+ Group = "vector";
+ Restart = "no";
+ StateDirectory = "vector";
+ ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+ AmbientCapabilities = "CAP_NET_BIND_SERVICE";
+ # This group is required for accessing journald.
+ SupplementaryGroups = mkIf cfg.journaldAccess "systemd-journal";
+ };
+ };
+ };
+}