mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-04 03:03:42 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
90 lines
2.1 KiB
Nix
90 lines
2.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.journalbeat;
|
|
|
|
journalbeatYml = pkgs.writeText "journalbeat.yml" ''
|
|
name: ${cfg.name}
|
|
tags: ${builtins.toJSON cfg.tags}
|
|
|
|
${cfg.extraConfig}
|
|
'';
|
|
|
|
in
|
|
{
|
|
options = {
|
|
|
|
services.journalbeat = {
|
|
|
|
enable = lib.mkEnableOption "journalbeat";
|
|
|
|
package = lib.mkPackageOption pkgs "journalbeat" { };
|
|
|
|
name = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "journalbeat";
|
|
description = "Name of the beat";
|
|
};
|
|
|
|
tags = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ ];
|
|
description = "Tags to place on the shipped log messages";
|
|
};
|
|
|
|
stateDir = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "journalbeat";
|
|
description = ''
|
|
Directory below `/var/lib/` to store journalbeat's
|
|
own logs and other data. This directory will be created automatically
|
|
using systemd's StateDirectory mechanism.
|
|
'';
|
|
};
|
|
|
|
extraConfig = lib.mkOption {
|
|
type = lib.types.lines;
|
|
default = "";
|
|
description = "Any other configuration options you want to add";
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
assertions = [
|
|
{
|
|
assertion = !lib.hasPrefix "/" cfg.stateDir;
|
|
message =
|
|
"The option services.journalbeat.stateDir shouldn't be an absolute directory."
|
|
+ " It should be a directory relative to /var/lib/.";
|
|
}
|
|
];
|
|
|
|
systemd.services.journalbeat = {
|
|
description = "Journalbeat log shipper";
|
|
wantedBy = [ "multi-user.target" ];
|
|
wants = [ "elasticsearch.service" ];
|
|
after = [ "elasticsearch.service" ];
|
|
preStart = ''
|
|
mkdir -p ${cfg.stateDir}/data
|
|
mkdir -p ${cfg.stateDir}/logs
|
|
'';
|
|
serviceConfig = {
|
|
StateDirectory = cfg.stateDir;
|
|
ExecStart = ''
|
|
${cfg.package}/bin/journalbeat \
|
|
-c ${journalbeatYml} \
|
|
-path.data /var/lib/${cfg.stateDir}/data \
|
|
-path.logs /var/lib/${cfg.stateDir}/logs'';
|
|
Restart = "always";
|
|
};
|
|
};
|
|
};
|
|
}
|