From 3ada6e2a16418676a182d2e2d5f9939240e20697 Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Thu, 8 Jan 2026 00:08:09 +0000 Subject: [PATCH] grafana-alloy: 1.11.3 -> 1.12.1 Grafana Alloy's frontend uses a npm lock file now --- pkgs/by-name/gr/grafana-alloy/package.nix | 72 ++++++++++------------- 1 file changed, 30 insertions(+), 42 deletions(-) diff --git a/pkgs/by-name/gr/grafana-alloy/package.nix b/pkgs/by-name/gr/grafana-alloy/package.nix index 2064257e78b3..0cdea5b59dd9 100644 --- a/pkgs/by-name/gr/grafana-alloy/package.nix +++ b/pkgs/by-name/gr/grafana-alloy/package.nix @@ -2,12 +2,9 @@ lib, stdenv, fetchFromGitHub, - fetchYarnDeps, buildGoModule, + buildNpmPackage, systemd, - yarn, - fixup-yarn-lock, - nodejs, grafana-alloy, nixosTests, nix-update-script, @@ -17,24 +14,39 @@ useLLD ? stdenv.hostPlatform.isArmv7, }: -buildGoModule (finalAttrs: { +buildGoModule (finalAttrs: rec { pname = "grafana-alloy"; - version = "1.11.3"; - + version = "1.12.1"; src = fetchFromGitHub { owner = "grafana"; repo = "alloy"; tag = "v${finalAttrs.version}"; - hash = "sha256-yO1r7GLXlD7f5Fpooit7SwkB7EB1hDO42o3BLvWY8Qo="; + hash = "sha256-DfezWaLbCty8FiFA+oEqiDoZ1QKIdYGtywQ6t2vm/N0="; }; + frontend = + let + fsrc = "${src}/internal/web/ui"; + in + buildNpmPackage { + pname = "alloy-frontend"; + inherit version; + + src = fsrc; + + npmDepsHash = "sha256-mEcPH+kuj+o60sK+JsRAwHauT7vHnZQZ+KBhKcDSeok="; + + installPhase = '' + mkdir $out + cp -av dist $out/share + ''; + + }; + proxyVendor = true; - vendorHash = "sha256-8n1r2Wun5ZSvjsU2Vl/fSRoQnTfKbrcQI6a7YDX/HZA="; + vendorHash = "sha256-pZNPJ4rSsvOHubCYKx+CblOUwI6eb6ckHwzRRtyRNu4="; nativeBuildInputs = [ - fixup-yarn-lock - yarn - nodejs installShellFiles ] ++ lib.optionals useLLD [ lld ]; @@ -62,39 +74,15 @@ buildGoModule (finalAttrs: { "promtail_journal_enabled" ]; + patchPhase = '' + # Copy frontend build in + cp -va "${frontend}/share" "internal/web/ui/dist" + ''; + subPackages = [ "." ]; - # Skip building the frontend in the goModules FOD - overrideModAttrs = ( - _: { - preBuild = null; - } - ); - - yarnOfflineCache = fetchYarnDeps { - yarnLock = "${finalAttrs.src}/internal/web/ui/yarn.lock"; - hash = "sha256-oCDP2XJczLXgzEjyvFEIFBanlnzjrj0So09izG5vufs="; - }; - - preBuild = '' - pushd internal/web/ui - - # Yarn wants a real home directory to write cache, config, etc to - export HOME=$NIX_BUILD_TOP/fake_home - - fixup-yarn-lock yarn.lock - yarn config --offline set yarn-offline-mirror ${finalAttrs.yarnOfflineCache} - yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive - - patchShebangs node_modules/ - - yarn --offline build - - popd - ''; - # uses go-systemd, which uses libsystemd headers # https://github.com/coreos/go-systemd/issues/351 NIX_CFLAGS_COMPILE = lib.optionals stdenv.hostPlatform.isLinux [ @@ -139,7 +127,7 @@ buildGoModule (finalAttrs: { ]; }; # alias for nix-update to be able to find and update this attribute - offlineCache = finalAttrs.yarnOfflineCache; + inherit frontend; }; meta = {