mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-15 10:12:58 +00:00
6afb255d97
these changes were generated with nixq 0.0.2, by running nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix two mentions of the mdDoc function remain in nixos/, both of which are inside of comments. Since lib.mdDoc is already defined as just id, this commit is a no-op as far as Nix (and the built manual) is concerned.
69 lines
2.0 KiB
Nix
69 lines
2.0 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) mkEnableOption mkPackageOption mkIf mkOption types getExe;
|
|
|
|
cfg = config.services.opentelemetry-collector;
|
|
opentelemetry-collector = cfg.package;
|
|
|
|
settingsFormat = pkgs.formats.yaml {};
|
|
in {
|
|
options.services.opentelemetry-collector = {
|
|
enable = mkEnableOption "Opentelemetry Collector";
|
|
|
|
package = mkPackageOption pkgs "opentelemetry-collector" { };
|
|
|
|
settings = mkOption {
|
|
type = settingsFormat.type;
|
|
default = {};
|
|
description = ''
|
|
Specify the configuration for Opentelemetry Collector in Nix.
|
|
|
|
See https://opentelemetry.io/docs/collector/configuration/ for available options.
|
|
'';
|
|
};
|
|
|
|
configFile = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
description = ''
|
|
Specify a path to a configuration file that Opentelemetry Collector should use.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
assertions = [{
|
|
assertion = (
|
|
(cfg.settings == {}) != (cfg.configFile == null)
|
|
);
|
|
message = ''
|
|
Please specify a configuration for Opentelemetry Collector with either
|
|
'services.opentelemetry-collector.settings' or
|
|
'services.opentelemetry-collector.configFile'.
|
|
'';
|
|
}];
|
|
|
|
systemd.services.opentelemetry-collector = {
|
|
description = "Opentelemetry Collector Service Daemon";
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = let
|
|
conf = if cfg.configFile == null
|
|
then settingsFormat.generate "config.yaml" cfg.settings
|
|
else cfg.configFile;
|
|
in
|
|
{
|
|
ExecStart = "${getExe opentelemetry-collector} --config=file:${conf}";
|
|
DynamicUser = true;
|
|
Restart = "always";
|
|
ProtectSystem = "full";
|
|
DevicePolicy = "closed";
|
|
NoNewPrivileges = true;
|
|
WorkingDirectory = "/var/lib/opentelemetry-collector";
|
|
StateDirectory = "opentelemetry-collector";
|
|
};
|
|
};
|
|
};
|
|
}
|