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.
This commit is contained in:
Maximilian Bosch
2024-01-23 23:10:52 +01:00
parent b1c52266c2
commit 4787b13af9
+15 -3
View File
@@ -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 { };