From 4787b13af9e9bde7775465597201285f0cd02b5e Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 23 Jan 2024 23:10:52 +0100 Subject: [PATCH] grafana: ensure that final derivation doesn't depend on yarn cache This saves 350M of runtime closure size. Also move the patching part of the offline cache into the patch phase. --- pkgs/servers/monitoring/grafana/default.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/monitoring/grafana/default.nix b/pkgs/servers/monitoring/grafana/default.nix index 4c2784e5ff01..3b4d930d4537 100644 --- a/pkgs/servers/monitoring/grafana/default.nix +++ b/pkgs/servers/monitoring/grafana/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, buildGoModule, fetchFromGitHub +{ lib, stdenv, buildGoModule, fetchFromGitHub, removeReferencesTo , tzdata, wire , yarn, nodejs, cacert , jq, moreutils @@ -50,14 +50,18 @@ buildGoModule rec { yarn nodejs cacert jq moreutils ]; - buildPhase = '' + postPatch = '' ${patchAwayGrafanaE2E} + ''; + buildPhase = '' + runHook preBuild export HOME="$(mktemp -d)" yarn config set enableTelemetry 0 yarn config set cacheFolder $out yarn config set --json supportedArchitectures.os '[ "linux" ]' yarn config set --json supportedArchitectures.cpu '["arm", "arm64", "ia32", "x64"]' yarn + runHook postBuild ''; dontConfigure = true; dontInstall = true; @@ -66,9 +70,11 @@ buildGoModule rec { outputHash = "sha256-70eMa8E483f/Bz7iy+4Seap1EfIdjD5krnt6W9CUows="; }; + disallowedRequisites = [ offlineCache ]; + vendorHash = "sha256-Gf2A22d7/8xU/ld7kveqGonVKGFCArGNansPRGhfyXM="; - nativeBuildInputs = [ wire yarn jq moreutils ]; + nativeBuildInputs = [ wire yarn jq moreutils removeReferencesTo ]; postPatch = '' ${patchAwayGrafanaE2E} @@ -145,6 +151,12 @@ buildGoModule rec { cp -r public conf $out/share/grafana/ ''; + postFixup = '' + while read line; do + remove-references-to -t $offlineCache "$line" + done < <(find $out -type f -name '*.js.map' -or -name '*.js') + ''; + passthru = { tests = { inherit (nixosTests) grafana; }; updateScript = nix-update-script { };