├── nix-relic.png ├── modules ├── nixos │ ├── default.nix │ └── newrelic-infra.nix └── darwin │ ├── default.nix │ ├── nr-otel-collector.nix │ └── newrelic-infra.nix ├── renovate.json ├── overlays └── default.nix ├── .github └── workflows │ ├── flakehub-publish-rolling.yml │ └── build.yaml ├── flake.lock ├── flake.nix ├── pkgs ├── nr-otel-collector │ ├── default.nix │ └── sources.nix ├── infrastructure-agent.nix ├── default.nix └── ocb.nix └── README.md /nix-relic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavSanchez/Nix-Relic/HEAD/nix-relic.png -------------------------------------------------------------------------------- /modules/nixos/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | newrelic-infra = import ./newrelic-infra.nix; 3 | } 4 | -------------------------------------------------------------------------------- /modules/darwin/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | newrelic-infra = import ./newrelic-infra.nix; 3 | nr-otel-collector = import ./nr-otel-collector.nix; 4 | } 5 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["config:recommended"], 4 | "lockFileMaintenance": { 5 | "enabled": true, 6 | "automerge": true, 7 | "extends": ["schedule:daily"] 8 | }, 9 | "nix": { 10 | "enabled": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /overlays/default.nix: -------------------------------------------------------------------------------- 1 | # This file defines overlays 2 | {inputs, ...}: { 3 | # This one brings our custom packages from the 'pkgs' directory 4 | additions = final: _prev: import ../pkgs {pkgs = final;}; 5 | 6 | # This one contains whatever you want to overlay 7 | # You can change versions, add patches, set compilation flags, anything really. 8 | # https://nixos.wiki/wiki/Overlays 9 | modifications = _final: _prev: { 10 | # example = prev.example.overrideAttrs (oldAttrs: rec { 11 | # ... 12 | # }); 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /.github/workflows/flakehub-publish-rolling.yml: -------------------------------------------------------------------------------- 1 | name: "Publish every Git push to master to FlakeHub" 2 | on: 3 | push: 4 | branches: 5 | - "master" 6 | jobs: 7 | flakehub-publish: 8 | runs-on: "ubuntu-latest" 9 | permissions: 10 | id-token: "write" 11 | contents: "read" 12 | steps: 13 | - uses: "actions/checkout@v5" 14 | - uses: "DeterminateSystems/nix-installer-action@main" 15 | - uses: "DeterminateSystems/flakehub-push@main" 16 | with: 17 | name: "DavSanchez/Nix-Relic" 18 | rolling: true 19 | visibility: "public" 20 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1760878510, 6 | "narHash": "sha256-K5Osef2qexezUfs0alLvZ7nQFTGS9DL2oTVsIXsqLgs=", 7 | "owner": "nixos", 8 | "repo": "nixpkgs", 9 | "rev": "5e2a59a5b1a82f89f2c7e598302a9cacebb72a67", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "nixos", 14 | "ref": "nixos-unstable", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Collection of infra observability tools packaged for Nix and accompanied by modules"; 3 | 4 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 5 | 6 | outputs = 7 | { nixpkgs, ... }@inputs: 8 | let 9 | # Supported systems for flake packages, shell, etc. 10 | systems = [ 11 | "aarch64-linux" 12 | "i686-linux" 13 | "x86_64-linux" 14 | "aarch64-darwin" 15 | "x86_64-darwin" 16 | ]; 17 | # This is a function that generates an attribute by calling a function you 18 | # pass to it, with each system as an argument 19 | forAllSystems = nixpkgs.lib.genAttrs systems; 20 | in 21 | { 22 | packages = forAllSystems (system: import ./pkgs { pkgs = nixpkgs.legacyPackages.${system}; }); 23 | 24 | nixosModules = import ./modules/nixos; 25 | 26 | darwinModules = import ./modules/darwin; 27 | 28 | overlays = import ./overlays { inherit inputs; }; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /pkgs/nr-otel-collector/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | pkgs, 4 | buildGoModule, 5 | ocb, 6 | }: 7 | let 8 | distName = "nr-otel-collector"; 9 | distVersion = "0.7.1"; 10 | generated-sources = pkgs.callPackage ./sources.nix { inherit ocb; }; 11 | in 12 | buildGoModule { 13 | pname = distName; 14 | version = distVersion; 15 | 16 | src = generated-sources; 17 | 18 | vendorHash = "sha256-75HGTKvmPpvrnJmZzuGscbDJQAvPid3W6VJogfa4ZWs="; 19 | 20 | ldflags = [ 21 | "-s" 22 | "-w" 23 | ]; 24 | 25 | # The TestGenerateAndCompile tests download new dependencies for a modified go.mod. Nix doesn't allow network access so skipping. 26 | checkFlags = [ "-skip TestValidateConfigs" ]; 27 | 28 | env.CGO_ENABLED = "0"; 29 | 30 | meta = with lib; { 31 | description = "The New Relic distribution of the OpenTelemetry Collector"; 32 | homepage = "https://github.com/newrelic/opentelemetry-collector-releases.git"; 33 | license = licenses.asl20; 34 | maintainers = with maintainers; [ DavSanchez ]; 35 | mainProgram = "nr-otel-collector"; 36 | platforms = platforms.all; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /pkgs/infrastructure-agent.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | stdenv, 4 | buildGoModule, 5 | fetchFromGitHub, 6 | }: 7 | buildGoModule rec { 8 | pname = "infrastructure-agent"; 9 | version = "1.58.0"; 10 | 11 | src = fetchFromGitHub { 12 | owner = "newrelic"; 13 | repo = "infrastructure-agent"; 14 | rev = version; 15 | hash = "sha256-L2er3DJ9zZb8AosHwOdNEsvQc7XPwQfGaa8d72iJOik="; 16 | }; 17 | 18 | vendorHash = "sha256-0WLL15CXRi/flp4EV3Qt0wO1VaUmAokzsChpiqjs+YQ="; 19 | 20 | ldflags = [ 21 | "-s" 22 | "-w" 23 | "-X main.buildVersion=${version}" 24 | "-X main.gitCommit=${src.rev}" 25 | ]; 26 | 27 | env.CGO_ENABLED = if stdenv.hostPlatform.isDarwin then "1" else "0"; 28 | 29 | subPackages = [ 30 | "cmd/newrelic-infra" 31 | "cmd/newrelic-infra-ctl" 32 | "cmd/newrelic-infra-service" 33 | ]; 34 | 35 | meta = { 36 | description = "New Relic Infrastructure Agent"; 37 | homepage = "https://github.com/newrelic/infrastructure-agent.git"; 38 | license = lib.licenses.asl20; 39 | maintainers = with lib.maintainers; [ davsanchez ]; 40 | mainProgram = "newrelic-infra"; 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /pkgs/default.nix: -------------------------------------------------------------------------------- 1 | # You can build the below packages using 'nix build .#example' 2 | {pkgs}: rec { 3 | infrastructure-agent = pkgs.callPackage ./infrastructure-agent.nix {}; 4 | ocb = pkgs.callPackage ./ocb.nix {}; 5 | 6 | nr-otel-collector = pkgs.callPackage ./nr-otel-collector { 7 | # nr-otel-collector needs a specific version of ocb at this moment, hence this hack 8 | ocb = let 9 | version = "0.86.0"; 10 | src = pkgs.fetchFromGitHub { 11 | owner = "open-telemetry"; 12 | repo = "opentelemetry-collector"; 13 | rev = "cmd/builder/v${version}"; 14 | hash = "sha256-Ucp00OjyPtHA6so/NOzTLtPSuhXwz6A2708w2WIZb/E="; 15 | fetchSubmodules = true; 16 | }; 17 | in 18 | # For why this was needed, see 19 | # https://discourse.nixos.org/t/inconsistent-vendoring-in-buildgomodule-when-overriding-source/9225/6 20 | ocb.override rec { 21 | buildGoModule = args: 22 | pkgs.buildGoModule (args 23 | // { 24 | inherit src version; 25 | vendorHash = "sha256-MTwD9xkrq3EudppLSoONgcPCBWlbSmaODLH9NtYgVOk="; 26 | }); 27 | }; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /pkgs/nr-otel-collector/sources.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | stdenv, 4 | fetchFromGitHub, 5 | ocb, 6 | }: 7 | let 8 | distVersion = "0.7.1"; 9 | in 10 | stdenv.mkDerivation { 11 | name = "collector-dist-${distVersion}"; 12 | src = fetchFromGitHub { 13 | owner = "newrelic"; 14 | repo = "opentelemetry-collector-releases"; 15 | rev = "nr-otel-collector-${distVersion}"; 16 | hash = "sha256-h6qxPDdKkyX8/GhOm/V/RfexnV/mbwmQ2hhFJDOXQaY="; 17 | }; 18 | nativeBuildInputs = 19 | (with pkgs; [ 20 | gnumake 21 | go 22 | ]) 23 | ++ [ ocb ]; 24 | buildPhase = '' 25 | # script run by make needs the correct bash location 26 | patchShebangs ./scripts/build.sh 27 | 28 | export HOME=$TMPDIR 29 | chmod -R u+w . 30 | make generate-sources 31 | ''; 32 | installPhase = '' 33 | # Remove log files as they make the build non-reproducible (contain dates) 34 | rm -rf distributions/nr-otel-collector/_build/build.log 35 | cp -r distributions/nr-otel-collector/_build/ $out 36 | ''; 37 | outputHashAlgo = "sha256"; 38 | outputHashMode = "recursive"; 39 | outputHash = "sha256-8mgMqZfSEsOY5gzAk1SA1IwHXPpAWEkfxQObaHHmJbg="; 40 | } 41 | -------------------------------------------------------------------------------- /pkgs/ocb.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | buildGoModule, 4 | fetchFromGitHub, 5 | }: 6 | buildGoModule rec { 7 | pname = "ocb"; 8 | version = "0.101.0"; 9 | 10 | src = fetchFromGitHub { 11 | owner = "open-telemetry"; 12 | repo = "opentelemetry-collector"; 13 | rev = "cmd/builder/v${version}"; 14 | hash = "sha256-Ucp00OjyPtHA6so/NOzTLtPSuhXwz6A2708w2WIZb/E="; 15 | }; 16 | 17 | sourceRoot = "${src.name}/cmd/builder"; 18 | vendorHash = "sha256-MTwD9xkrq3EudppLSoONgcPCBWlbSmaODLH9NtYgVOk="; 19 | 20 | GOFLAGS = [ "-trimpath" ]; 21 | env.CGO_ENABLED = 0; 22 | ldflags = [ 23 | "-s" 24 | "-w" 25 | "-X go.opentelemetry.io/collector/cmd/builder/internal.version=${version}" 26 | ]; 27 | 28 | # The TestGenerateAndCompile tests download new dependencies for a modified go.mod. Nix doesn't allow network access so skipping. 29 | checkFlags = [ "-skip TestGenerateAndCompile" ]; 30 | 31 | # Rename the to ocb (it's generated as "builder") 32 | postInstall = '' 33 | mv $out/bin/builder $out/bin/ocb 34 | ''; 35 | 36 | meta = { 37 | description = "OpenTelemetry Collector"; 38 | homepage = "https://github.com/open-telemetry/opentelemetry-collector.git"; 39 | changelog = "https://github.com/open-telemetry/opentelemetry-collector/blob/${src.rev}/CHANGELOG.md"; 40 | license = lib.licenses.asl20; 41 | maintainers = with lib.maintainers; [ DavSanchez ]; 42 | mainProgram = "ocb"; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Build tests" 3 | on: 4 | pull_request: 5 | branches: [master] 6 | push: 7 | branches: [master] 8 | jobs: 9 | checks: 10 | runs-on: ${{ matrix.os }} 11 | strategy: 12 | matrix: 13 | os: [ubuntu-latest, macos-latest] 14 | 15 | steps: 16 | - uses: actions/checkout@v5 17 | 18 | - name: Install Nix 19 | uses: cachix/install-nix-action@v31 20 | with: 21 | github_access_token: ${{ secrets.GITHUB_TOKEN }} 22 | 23 | - name: Enable binary cache with Cachix 24 | uses: cachix/cachix-action@v16 25 | with: 26 | name: nix-relic 27 | # If you chose API tokens for write access OR if you have a private cache 28 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' 29 | 30 | - name: Run Nix checks 31 | run: nix flake check 32 | 33 | build: 34 | needs: [checks] 35 | runs-on: ${{ matrix.os }} 36 | strategy: 37 | matrix: 38 | os: [ubuntu-latest, macos-latest] 39 | pkg: [infrastructure-agent, ocb, nr-otel-collector] 40 | 41 | steps: 42 | - uses: actions/checkout@v5 43 | 44 | - name: Install Nix 45 | uses: cachix/install-nix-action@v31 46 | with: 47 | github_access_token: ${{ secrets.GITHUB_TOKEN }} 48 | 49 | - name: Enable binary cache with Cachix 50 | uses: cachix/cachix-action@v16 51 | with: 52 | name: nix-relic 53 | # If you chose API tokens for write access OR if you have a private cache 54 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' 55 | 56 | - name: Build ${{ matrix.pkg }} with Nix 57 | run: nix build --print-out-paths ".#${{ matrix.pkg }}" 58 | -------------------------------------------------------------------------------- /modules/darwin/nr-otel-collector.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | pkgs, 4 | config, 5 | ... 6 | }: let 7 | inherit (lib) mkEnableOption mkIf mkOption types mdDoc getExe; 8 | cfg = config.services.nr-otel-collector; 9 | settingsFormat = pkgs.formats.yaml {}; 10 | in { 11 | options.services.nr-otel-collector = { 12 | enable = mkEnableOption "New Relic distribution for OpenTelemetry Collector service"; 13 | 14 | settings = mkOption { 15 | type = settingsFormat.type; 16 | default = {}; 17 | description = mdDoc '' 18 | Specify the configuration for Opentelemetry Collector in Nix. 19 | 20 | See for available options. 21 | ''; 22 | }; 23 | configFile = mkOption { 24 | type = types.nullOr types.path; 25 | default = null; 26 | description = mdDoc '' 27 | Specify a path to a configuration file that Opentelemetry Collector should use. 28 | ''; 29 | }; 30 | 31 | logFile = mkOption { 32 | type = types.path; 33 | default = "/var/log/nr-otel-collector/nr-otel-collector.log"; 34 | description = mdDoc "Path to the log file"; 35 | }; 36 | 37 | errLogFile = mkOption { 38 | type = types.path; 39 | default = "/var/log/nr-otel-collector/nr-otel-collector.stderr.log"; 40 | description = mdDoc "Path to the error log file"; 41 | }; 42 | }; 43 | 44 | config = mkIf cfg.enable { 45 | launchd.daemons.nr-otel-collector = let 46 | conf = 47 | if cfg.configFile == null 48 | then settingsFormat.generate "config.yaml" cfg.settings 49 | else cfg.configFile; 50 | in { 51 | # path = [ pkgs.nr-otel-collector pkgs.ps ]; 52 | 53 | serviceConfig = { 54 | ProgramArguments = [ "${getExe pkgs.nr-otel-collector}" "--config=file:${conf}" ]; 55 | KeepAlive = true; 56 | RunAtLoad = true; 57 | StandardErrorPath = cfg.errLogFile; 58 | StandardOutPath = cfg.logFile; 59 | }; 60 | }; 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /modules/darwin/newrelic-infra.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | pkgs, 4 | config, 5 | ... 6 | }: let 7 | inherit (lib) mkEnableOption mkIf mkOption types mdDoc; 8 | cfg = config.services.newrelic-infra; 9 | settingsFormat = pkgs.formats.yaml {}; 10 | in { 11 | options.services.newrelic-infra = { 12 | enable = mkEnableOption "newrelic-infra service"; 13 | 14 | settings = mkOption { 15 | type = settingsFormat.type; 16 | default = {}; 17 | description = mdDoc '' 18 | Specify the configuration for the Infra Agent in Nix. 19 | 20 | See for available options. 21 | ''; 22 | }; 23 | configFile = mkOption { 24 | type = types.nullOr types.path; 25 | default = null; 26 | description = mdDoc '' 27 | Specify a path to a configuration file that the Infrastructure Agent should use. 28 | ''; 29 | }; 30 | 31 | logFile = mkOption { 32 | type = types.path; 33 | default = "/var/log/newrelic-infra/newrelic-infra.log"; 34 | description = mdDoc "Path to the log file"; 35 | }; 36 | 37 | errLogFile = lib.mkOption { 38 | type = types.path; 39 | default = "/var/log/newrelic-infra/newrelic-infra.stderr.log"; 40 | description = mdDoc "Path to the error log file"; 41 | }; 42 | }; 43 | 44 | config = mkIf cfg.enable { 45 | launchd.daemons.newrelic-infra = let 46 | conf = 47 | if cfg.configFile == null 48 | then settingsFormat.generate "config.yaml" cfg.settings 49 | else cfg.configFile; 50 | in { 51 | path = [ pkgs.infrastructure-agent ]; 52 | 53 | serviceConfig = { 54 | ProgramArguments = [ "${pkgs.infrastructure-agent}/bin/newrelic-infra-service" "-config" "${conf}" ]; 55 | KeepAlive = true; 56 | RunAtLoad = true; 57 | StandardErrorPath = cfg.errLogFile; 58 | StandardOutPath = cfg.logFile; 59 | }; 60 | }; 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /modules/nixos/newrelic-infra.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | pkgs, 4 | config, 5 | ... 6 | }: let 7 | inherit (lib) mkEnableOption mkIf mkOption types mdDoc; 8 | 9 | cfg = config.services.newrelic-infra; 10 | settingsFormat = pkgs.formats.yaml {}; 11 | in { 12 | options.services.newrelic-infra = { 13 | enable = lib.mkEnableOption "newrelic-infra service"; 14 | # TODO: withIntegrations = [ drv drv ... ]; 15 | 16 | settings = mkOption { 17 | type = settingsFormat.type; 18 | default = {}; 19 | description = mdDoc '' 20 | Specify the configuration for the Infra Agent in Nix. 21 | 22 | See for available options. 23 | ''; 24 | }; 25 | configFile = mkOption { 26 | type = types.nullOr types.path; 27 | default = null; 28 | description = mdDoc '' 29 | Specify a path to a configuration file that the Infrastructure Agent should use. 30 | ''; 31 | }; 32 | }; 33 | 34 | config = mkIf cfg.enable { 35 | systemd.services.newrelic-infra = { 36 | description = "New Relic Infrastructure Agent"; 37 | 38 | after = [ 39 | "dbus.service" 40 | "syslog.target" 41 | "network.target" 42 | ]; 43 | 44 | serviceConfig = let 45 | conf = 46 | if cfg.configFile == null 47 | then settingsFormat.generate "config.yaml" cfg.settings 48 | else cfg.configFile; 49 | in { 50 | RuntimeDirectory = "newrelic-infra"; 51 | Type = "simple"; 52 | ExecStart = "${pkgs.infrastructure-agent}/bin/newrelic-infra-service -config ${conf}"; 53 | MemoryMax = "1G"; 54 | Restart = "always"; 55 | RestartSec = 20; 56 | PIDFile = "/run/newrelic-infra/newrelic-infra.pid"; 57 | }; 58 | 59 | unitConfig = { 60 | StartLimitInterval = 0; 61 | StartLimitBurst = 5; 62 | }; 63 | 64 | wantedBy = ["multi-user.target"]; 65 | }; 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [logo](https://github.com/DavSanchez/Nix-Relic) 3 | 4 | # Nix Relic 5 | 6 | [![Build tests](https://github.com/DavSanchez/Nix-Relic/actions/workflows/build.yaml/badge.svg)](https://github.com/DavSanchez/Nix-Relic/actions/workflows/build.yaml) 7 | 8 | [![built with nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org) 9 | 10 | This is a collection of some infrastructure observability tools from New Relic packaged as Nix Flakes and accompanied by NixOS and nix-darwin modules. 11 | 12 | ## Usage as a flake 13 | 14 | Add Nix-Relic to your `flake.nix`: 15 | 16 | ```nix 17 | { 18 | nix-relic.url = "github:DavSanchez/Nix-Relic" 19 | # and, optionally 20 | # nix-relic.inputs.nixpkgs.follows = "nixpkgs"; 21 | 22 | outputs = { self, Nix-Relic }: { 23 | # Use in your outputs with one of the two commented options below 24 | nixosConfigurations = { 25 | my-host = nixpkgs.lib.nixosSystem { 26 | system = "x86_64-linux"; 27 | specialArgs = { 28 | # This makes the modules available from `imports` on your configuration file 29 | inherit inputs; 30 | }; 31 | modules = [ 32 | ./path/to/my-host/configuration.nix 33 | # Or you can add the module directly here to expose the options 34 | inputs.nix-relic.nixosModules.newrelic-infra 35 | ]; 36 | }; 37 | }; 38 | }; 39 | } 40 | ``` 41 | 42 | ## Available modules 43 | 44 | ### Adding the packages from `nix-relic`'s overlay 45 | 46 | It might be possible that the modules defined here reference packages that are not yet present 47 | in `nixpkgs`. At the time of writing this, this is the case for the 48 | New Relic distribution for the OpenTelemetry Collector (package `nr-otel-collector`). 49 | 50 | If you encounter this problem, add this flake's default overlay to your `nixpkgs.overlays` config. 51 | Assuming you have named this flake input as `nix-relic`: 52 | 53 | ```nix 54 | { 55 | nixpkgs = { 56 | overlays = [ 57 | inputs.nix-relic.overlays.additions 58 | ]; 59 | }; 60 | } 61 | ``` 62 | 63 | ### NixOS 64 | 65 | #### Infrastructure agent `systemd` service 66 | 67 | ```nix 68 | { 69 | services.newrelic-infra = { 70 | enable = true; 71 | # Beware of including license keys to the file defined below! 72 | # The file will end up added in plain text to the Nix Store. 73 | # Use encryption tools like `agenix` or `sops-nix` to handle this in a secure manner. 74 | configFile = ./newrelic-infra.yml; 75 | }; 76 | } 77 | ``` 78 | 79 | #### Use the New Relic Distribution for OpenTelemetry Collector 80 | 81 | A module for setting up an OpenTelemetry collector is already provided by NixOS, 82 | we only need to change it so it uses our New Relic Distribution package: 83 | 84 | ```nix 85 | { 86 | services.opentelemetry-collector = { 87 | enable = true; 88 | package = pkgs.nr-otel-collector; # Here! 89 | configFile = ./nr-otel-collector.yaml; 90 | }; 91 | } 92 | ``` 93 | 94 | ### Darwin (macOS) 95 | 96 | #### Infrastructure agent `launchd` daemon 97 | 98 | ```nix 99 | { 100 | services.newrelic-infra = { 101 | enable = true; 102 | # Beware of including license keys to the file defined below! 103 | # The file will end up added in plain text to the Nix Store. 104 | # Use encryption tools like `agenix` or `sops-nix` to handle this in a secure manner. 105 | configFile = ./newrelic-infra.yml; 106 | logFile = ./path/to/file.log; 107 | errLogFile = ./path/to/errfile.log; 108 | }; 109 | } 110 | ``` 111 | 112 | #### New Relic Distribution for OpenTelemetry Collector `launchd` daemon 113 | 114 | ```nix 115 | { 116 | services.nr-otel-collector = { 117 | enable = true; 118 | configFile = ./nr-otel-collector.yml; 119 | logFile = ./path/to/file.log; 120 | errLogFile = ./path/to/errfile.log; 121 | }; 122 | } 123 | ``` 124 | 125 | ## Security 126 | 127 | Beware of including license keys to the files defined in the configs, such as the one passed to 128 | `services.newrelic-infra.configFile`. These files will end up added in plain text to the Nix Store. 129 | 130 | Use Nix secret management utilities like [`agenix`](https://github.com/ryantm/agenix) 131 | or [`sops-nix`](https://github.com/Mic92/sops-nix) to handle this securely. 132 | 133 | ## Available packages 134 | 135 | ### New Relic Infrastructure Agent 136 | 137 | ```sh 138 | # Make it available in your shell 139 | nix shell github:DavSanchez/Nix-Relic#infrastructure-agent 140 | 141 | # or build the package and find the outputs in ./result 142 | nix build github:DavSanchez/Nix-Relic#infrastructure-agent 143 | ``` 144 | 145 | ### OpenTelemetry Collector Builder (OCB) 146 | 147 | ```sh 148 | # Make it available in your shell 149 | nix shell github:DavSanchez/Nix-Relic#ocb 150 | 151 | # or build the package and find the outputs in ./result 152 | nix build github:DavSanchez/Nix-Relic#ocb 153 | ``` 154 | 155 | ### New Relic Distribution for OpenTelemetry Collector 156 | 157 | ```sh 158 | # Make it available in your shell 159 | nix shell github:DavSanchez/Nix-Relic#nr-otel-collector 160 | 161 | # or build the package and find the outputs in ./result 162 | nix build github:DavSanchez/Nix-Relic#nr-otel-collector 163 | ``` 164 | --------------------------------------------------------------------------------