This is a collection of some infrastructure observability tools from New Relic packaged as Nix Flakes and accompanied by NixOS and nix-darwin modules.
Add Nix-Relic to your flake.nix
:
{
nix-relic.url = "github:DavSanchez/Nix-Relic"
# and, optionally
# nix-relic.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, Nix-Relic }: {
# Use in your outputs with one of the two commented options below
nixosConfigurations = {
my-host = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
# This makes the modules available from `imports` on your configuration file
inherit inputs;
};
modules = [
./path/to/my-host/configuration.nix
# Or you can add the module directly here to expose the options
inputs.nix-relic.nixosModules.newrelic-infra
];
};
};
};
}
It might be possible that the modules defined here reference packages that are not yet present
in nixpkgs
. At the time of writing this, this is the case for the
New Relic distribution for the OpenTelemetry Collector (package nr-otel-collector
).
If you encounter this problem, add this flake's default overlay to your nixpkgs.overlays
config.
Assuming you have named this flake input as nix-relic
:
{
nixpkgs = {
overlays = [
inputs.nix-relic.overlays.additions
];
};
}
{
services.newrelic-infra = {
enable = true;
# Beware of including license keys to the file defined below!
# The file will end up added in plain text to the Nix Store.
# Use encryption tools like `agenix` or `sops-nix` to handle this in a secure manner.
configFile = ./newrelic-infra.yml;
};
}
A module for setting up an OpenTelemetry collector is already provided by NixOS, we only need to change it so it uses our New Relic Distribution package:
{
services.opentelemetry-collector = {
enable = true;
package = pkgs.nr-otel-collector; # Here!
configFile = ./nr-otel-collector.yaml;
};
}
{
services.newrelic-infra = {
enable = true;
# Beware of including license keys to the file defined below!
# The file will end up added in plain text to the Nix Store.
# Use encryption tools like `agenix` or `sops-nix` to handle this in a secure manner.
configFile = ./newrelic-infra.yml;
logFile = ./path/to/file.log;
errLogFile = ./path/to/errfile.log;
};
}
{
services.nr-otel-collector = {
enable = true;
configFile = ./nr-otel-collector.yml;
logFile = ./path/to/file.log;
errLogFile = ./path/to/errfile.log;
};
}
Beware of including license keys to the files defined in the configs, such as the one passed to
services.newrelic-infra.configFile
. These files will end up added in plain text to the Nix Store.
Use Nix secret management utilities like agenix
or sops-nix
to handle this securely.
# Make it available in your shell
nix shell github:DavSanchez/Nix-Relic#infrastructure-agent
# or build the package and find the outputs in ./result
nix build github:DavSanchez/Nix-Relic#infrastructure-agent
# Make it available in your shell
nix shell github:DavSanchez/Nix-Relic#ocb
# or build the package and find the outputs in ./result
nix build github:DavSanchez/Nix-Relic#ocb
# Make it available in your shell
nix shell github:DavSanchez/Nix-Relic#nr-otel-collector
# or build the package and find the outputs in ./result
nix build github:DavSanchez/Nix-Relic#nr-otel-collector