Unverified Commit 4496a910 authored by Florian Klink's avatar Florian Klink Committed by GitHub
Browse files

Merge pull request #225973 from IndeedNotJames/grafana-agent

grafana-agent: 0.30.2 -> 0.32.1, remove obsolete test fix; nixos/grafana-agent: use `lib.getExe`
parents 70fec8b2 7275cfa7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ in
        # We can't use Environment=HOSTNAME=%H, as it doesn't include the domain part.
        export HOSTNAME=$(< /proc/sys/kernel/hostname)

        exec ${cfg.package}/bin/agent -config.expand-env -config.file ${configFile}
        exec ${lib.getExe cfg.package} -config.expand-env -config.file ${configFile}
      '';
      serviceConfig = {
        Restart = "always";
+9 −13
Original line number Diff line number Diff line
@@ -2,16 +2,17 @@

buildGoModule rec {
  pname = "grafana-agent";
  version = "0.30.2";
  version = "0.32.1";

  src = fetchFromGitHub {
    rev = "v${version}";
    owner = "grafana";
    repo = "agent";
    sha256 = "sha256-yexCK4GBA997CShtuQQTs1GBsXoknUnWWO0Uotb9EG8=";
    sha256 = "sha256-t5rQSNLpX0ktK4mKgX6OhNLkANQ1LbFEjmQo/r7UHOM=";
  };

  vendorHash = "sha256-Cl3oygH1RPF+ZdJvkDmr7eyU5daxaZwNE8pQOHK/qP4=";
  vendorHash = "sha256-5beHG1mZkNcDhccleqTlMA+uiV5d6SSh2QWiL4g3O28=";
  proxyVendor = true; # darwin/linux hash mismatch

  ldflags = let
    prefix = "github.com/grafana/agent/pkg/build";
@@ -32,26 +33,21 @@ buildGoModule rec {
  ];

  subPackages = [
    "cmd/agent"
    "cmd/agentctl"
    "cmd/grafana-agent"
    "cmd/grafana-agentctl"
  ];

  # uses go-systemd, which uses libsystemd headers
  # https://github.com/coreos/go-systemd/issues/351
  env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.isLinux [ "-I${lib.getDev systemd}/include" ]);

  # tries to access /sys: https://github.com/grafana/agent/issues/333
  preBuild = ''
    rm pkg/integrations/node_exporter/node_exporter_test.go
  '';

  # go-systemd uses libsystemd under the hood, which does dlopen(libsystemd) at
  # runtime.
  # Add to RUNPATH so it can be found.
  postFixup = lib.optionalString stdenv.isLinux ''
    patchelf \
      --set-rpath "${lib.makeLibraryPath [ (lib.getLib systemd) ]}:$(patchelf --print-rpath $out/bin/agent)" \
      $out/bin/agent
      --set-rpath "${lib.makeLibraryPath [ (lib.getLib systemd) ]}:$(patchelf --print-rpath $out/bin/grafana-agent)" \
      $out/bin/grafana-agent
  '';

  passthru.tests.grafana-agent = nixosTests.grafana-agent;
@@ -60,6 +56,6 @@ buildGoModule rec {
    description = "A lightweight subset of Prometheus and more, optimized for Grafana Cloud";
    license = licenses.asl20;
    homepage = "https://grafana.com/products/cloud";
    maintainers = with maintainers; [ flokli ];
    maintainers = with maintainers; [ flokli indeednotjames ];
  };
}