Merge pull request #246853 from emilylange/grafana-agent-flow-assets

grafana-agent: build and embed flow mode web ui
This commit is contained in:
Florian Klink 2023-08-28 10:40:36 +03:00 committed by GitHub
commit 88c10505ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,15 @@
{ lib
, buildGoModule
, fetchFromGitHub
, fetchYarnDeps
, fixup_yarn_lock
, grafana-agent
, nixosTests
, nodejs
, stdenv
, systemd
, testers
, yarn
}:
buildGoModule rec {
@ -22,6 +26,11 @@ buildGoModule rec {
vendorHash = "sha256-vzrp20Mg6AA0h3+5+qbKRa7nhx/hgiIHG6RNXLATpHE=";
proxyVendor = true; # darwin/linux hash mismatch
frontendYarnOfflineCache = fetchYarnDeps {
yarnLock = src + "/web/ui/yarn.lock";
hash = "sha256-xJEPubIDjlZQL70UGha1MHbeek6KFPaxZGb5IRgMlTA=";
};
ldflags = let
prefix = "github.com/grafana/agent/pkg/build";
in [
@ -34,7 +43,10 @@ buildGoModule rec {
"-X ${prefix}.BuildDate=1980-01-01T00:00:00Z"
];
nativeBuildInputs = [ fixup_yarn_lock nodejs yarn ];
tags = [
"builtinassets"
"nonetwork"
"nodocker"
"promtail_journal_enabled"
@ -43,8 +55,21 @@ buildGoModule rec {
subPackages = [
"cmd/grafana-agent"
"cmd/grafana-agentctl"
"web/ui"
];
preBuild = ''
export HOME="$TMPDIR"
pushd web/ui
fixup_yarn_lock yarn.lock
yarn config --offline set yarn-offline-mirror $frontendYarnOfflineCache
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules
yarn --offline run build
popd
'';
# 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" ]);