about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/monitoring/grafana/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/servers/monitoring/grafana/default.nix')
-rw-r--r--nixpkgs/pkgs/servers/monitoring/grafana/default.nix35
1 files changed, 25 insertions, 10 deletions
diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/default.nix
index 99846f7babfe..dd44fa6017c0 100644
--- a/nixpkgs/pkgs/servers/monitoring/grafana/default.nix
+++ b/nixpkgs/pkgs/servers/monitoring/grafana/default.nix
@@ -2,7 +2,7 @@
 , tzdata, wire
 , yarn, nodejs, python3, cacert
 , jq, moreutils
-, nix-update-script, nixosTests
+, nix-update-script, nixosTests, xcbuild
 }:
 
 let
@@ -21,7 +21,7 @@ let
 in
 buildGoModule rec {
   pname = "grafana";
-  version = "10.4.0";
+  version = "10.4.1";
 
   subPackages = [ "pkg/cmd/grafana" "pkg/cmd/grafana-server" "pkg/cmd/grafana-cli" ];
 
@@ -29,16 +29,24 @@ buildGoModule rec {
     owner = "grafana";
     repo = "grafana";
     rev = "v${version}";
-    hash = "sha256-Rp2jGspbmqJFzSbiVy2/5oqQJnAdGG/T+VNBHVsHSwg=";
+    hash = "sha256-wKYn6EcfQlWj/6rKnGYphzq3IThRj6qCjpqwllNPht8=";
+  };
+
+  # borrowed from: https://github.com/NixOS/nixpkgs/blob/d70d9425f49f9aba3c49e2c389fe6d42bac8c5b0/pkgs/development/tools/analysis/snyk/default.nix#L20-L22
+  env = lib.optionalAttrs (stdenv.isDarwin && stdenv.isx86_64) {
+    # Fix error: no member named 'aligned_alloc' in the global namespace.
+    # Occurs while building @esfx/equatable@npm:1.0.2 on x86_64-darwin
+    NIX_CFLAGS_COMPILE = "-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION=1";
   };
 
   offlineCache = stdenv.mkDerivation {
     name = "${pname}-${version}-yarn-offline-cache";
-    inherit src;
+    inherit src env;
     nativeBuildInputs = [
       yarn nodejs cacert
       jq moreutils python3
-    ];
+    # @esfx/equatable@npm:1.0.2 fails to build on darwin as it requires `xcbuild`
+    ] ++ lib.optionals stdenv.isDarwin [ xcbuild.xcbuild ];
     postPatch = ''
       ${patchAwayGrafanaE2E}
     '';
@@ -47,7 +55,7 @@ buildGoModule rec {
       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.os '[ "linux", "darwin" ]'
       yarn config set --json supportedArchitectures.cpu '["arm", "arm64", "ia32", "x64"]'
       yarn
       runHook postBuild
@@ -56,14 +64,21 @@ buildGoModule rec {
     dontInstall = true;
     dontFixup = true;
     outputHashMode = "recursive";
-    outputHash = "sha256-QdyXSPshzugkDTJoUrJlHNuhPAyR9gae5Cbk8Q8FSl4=";
+    outputHash = rec {
+      x86_64-linux = "sha256-3CZgs732c6Z64t2sfWjPAmMFKVTzoolv2TwrbjeRCBA=";
+      aarch64-linux = x86_64-linux;
+      aarch64-darwin = "sha256-NKEajOe9uDZw0MF5leiKBIRH1CHUELRho7gyCa96BO8=";
+      x86_64-darwin = aarch64-darwin;
+    }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
   };
 
   disallowedRequisites = [ offlineCache ];
 
-  vendorHash = "sha256-cNkMVLXp3hPMcW0ilOM0VlrrDX/IsZaze+/6qlTfmRs=";
+  vendorHash = "sha256-puPgbgfRqbPvMVks+gyOPOTTfdClWqbOf89X0ihMLPY=";
+
+  proxyVendor = true;
 
-  nativeBuildInputs = [ wire yarn jq moreutils removeReferencesTo python3 ];
+  nativeBuildInputs = [ wire yarn jq moreutils removeReferencesTo python3 ] ++ lib.optionals stdenv.isDarwin [ xcbuild.xcbuild ];
 
   postPatch = ''
     ${patchAwayGrafanaE2E}
@@ -137,7 +152,7 @@ buildGoModule rec {
     license = licenses.agpl3Only;
     homepage = "https://grafana.com";
     maintainers = with maintainers; [ offline fpletz willibutz globin ma27 Frostman ];
-    platforms = platforms.linux ++ platforms.darwin;
+    platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
     mainProgram = "grafana-server";
   };
 }