17 pname = "grafana-agent";
20 src = fetchFromGitHub {
24 hash = "sha256-A/h8Mwtor4VUT7e7TsNiE/0OOXCSq38GAf9j7c8ZDKk=";
27 vendorHash = "sha256-W29GZoZfgjdSwGiFz4udGA9gXgmM0xIDEGld7ZE1ycQ=";
28 proxyVendor = true; # darwin/linux hash mismatch
30 frontendYarnOfflineCache = fetchYarnDeps {
31 yarnLock = src + "/internal/web/ui/yarn.lock";
32 hash = "sha256-WqbIg18qUNcs9O2wh7DAzwXKb60iEuPL8zFCIgScqI0=";
36 prefix = "github.com/grafana/agent/internal/build";
39 # https://github.com/grafana/agent/blob/v0.41.0/Makefile#L132-L137
40 "-X ${prefix}.Version=${version}"
41 "-X ${prefix}.Branch=v${version}"
42 "-X ${prefix}.Revision=v${version}"
43 "-X ${prefix}.BuildUser=nix"
44 "-X ${prefix}.BuildDate=1980-01-01T00:00:00Z"
47 nativeBuildInputs = [ fixup-yarn-lock nodejs yarn ];
53 "promtail_journal_enabled"
58 "cmd/grafana-agentctl"
66 fixup-yarn-lock yarn.lock
67 yarn config --offline set yarn-offline-mirror $frontendYarnOfflineCache
68 yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
69 patchShebangs node_modules
70 yarn --offline run build
74 # do not pass preBuild to go-modules.drv, as it would otherwise fail to build.
75 # but even if it would work, it simply isn't needed in that scope.
76 overrideModAttrs = (_: {
80 # uses go-systemd, which uses libsystemd headers
81 # https://github.com/coreos/go-systemd/issues/351
82 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.isLinux [ "-I${lib.getDev systemd}/include" ]);
84 # go-systemd uses libsystemd under the hood, which does dlopen(libsystemd) at
86 # Add to RUNPATH so it can be found.
87 postFixup = lib.optionalString stdenv.isLinux ''
89 --set-rpath "${lib.makeLibraryPath [ (lib.getLib systemd) ]}:$(patchelf --print-rpath $out/bin/grafana-agent)" \
90 $out/bin/grafana-agent
95 inherit (nixosTests) grafana-agent;
96 version = testers.testVersion {
98 command = "${lib.getExe grafana-agent} --version";
99 package = grafana-agent;
102 updateScript = nix-update-script { };
103 # alias for nix-update to be able to find and update this attribute
104 offlineCache = frontendYarnOfflineCache;
108 description = "Lightweight subset of Prometheus and more, optimized for Grafana Cloud";
109 license = lib.licenses.asl20;
110 homepage = "https://grafana.com/products/cloud";
111 changelog = "https://github.com/grafana/agent/blob/${src.rev}/CHANGELOG.md";
112 maintainers = with lib.maintainers; [ flokli emilylange ];
113 mainProgram = "grafana-agent";