diff options
Diffstat (limited to 'nixpkgs/pkgs/servers/monitoring/grafana')
15 files changed, 367 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/default.nix new file mode 100644 index 000000000000..dd44fa6017c0 --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/default.nix @@ -0,0 +1,158 @@ +{ lib, stdenv, buildGoModule, fetchFromGitHub, removeReferencesTo +, tzdata, wire +, yarn, nodejs, python3, cacert +, jq, moreutils +, nix-update-script, nixosTests, xcbuild +}: + +let + # We need dev dependencies to run webpack, but patch away + # `cypress` (and @grafana/e2e which has a direct dependency on cypress). + # This attempts to download random blobs from the Internet in + # postInstall. Also, it's just a testing framework, so not worth the hassle. + patchAwayGrafanaE2E = '' + find . -name package.json | while IFS=$'\n' read -r pkg_json; do + <"$pkg_json" jq '. + { + "devDependencies": .devDependencies | del(."@grafana/e2e") | del(.cypress) + }' | sponge "$pkg_json" + done + rm -r packages/grafana-e2e + ''; +in +buildGoModule rec { + pname = "grafana"; + version = "10.4.1"; + + subPackages = [ "pkg/cmd/grafana" "pkg/cmd/grafana-server" "pkg/cmd/grafana-cli" ]; + + src = fetchFromGitHub { + owner = "grafana"; + repo = "grafana"; + rev = "v${version}"; + 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 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} + ''; + buildPhase = '' + runHook preBuild + export HOME="$(mktemp -d)" + yarn config set enableTelemetry 0 + yarn config set cacheFolder $out + yarn config set --json supportedArchitectures.os '[ "linux", "darwin" ]' + yarn config set --json supportedArchitectures.cpu '["arm", "arm64", "ia32", "x64"]' + yarn + runHook postBuild + ''; + dontConfigure = true; + dontInstall = true; + dontFixup = true; + outputHashMode = "recursive"; + 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-puPgbgfRqbPvMVks+gyOPOTTfdClWqbOf89X0ihMLPY="; + + proxyVendor = true; + + nativeBuildInputs = [ wire yarn jq moreutils removeReferencesTo python3 ] ++ lib.optionals stdenv.isDarwin [ xcbuild.xcbuild ]; + + postPatch = '' + ${patchAwayGrafanaE2E} + ''; + + postConfigure = '' + # Generate DI code that's required to compile the package. + # From https://github.com/grafana/grafana/blob/v8.2.3/Makefile#L33-L35 + wire gen -tags oss ./pkg/server + wire gen -tags oss ./pkg/cmd/grafana-cli/runner + + GOARCH= CGO_ENABLED=0 go generate ./pkg/plugins/plugindef + GOARCH= CGO_ENABLED=0 go generate ./kinds/gen.go + GOARCH= CGO_ENABLED=0 go generate ./public/app/plugins/gen.go + # Setup node_modules + export HOME="$(mktemp -d)" + + # Help node-gyp find Node.js headers + # (see https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/javascript.section.md#pitfalls-javascript-yarn2nix-pitfalls) + mkdir -p $HOME/.node-gyp/${nodejs.version} + echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion + ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version} + export npm_config_nodedir=${nodejs} + + yarn config set enableTelemetry 0 + yarn config set cacheFolder $offlineCache + yarn --immutable-cache + + # The build OOMs on memory constrained aarch64 without this + export NODE_OPTIONS=--max_old_space_size=4096 + ''; + + postBuild = '' + # After having built all the Go code, run the JS builders now. + yarn run build + yarn run plugins:build-bundled + ''; + + ldflags = [ + "-s" "-w" "-X main.version=${version}" + ]; + + # Tests start http servers which need to bind to local addresses: + # panic: httptest: failed to listen on a port: listen tcp6 [::1]:0: bind: operation not permitted + __darwinAllowLocalNetworking = true; + + # On Darwin, files under /usr/share/zoneinfo exist, but fail to open in sandbox: + # TestValueAsTimezone: date_formats_test.go:33: Invalid has err for input "Europe/Amsterdam": operation not permitted + preCheck = '' + export ZONEINFO=${tzdata}/share/zoneinfo + ''; + + postInstall = '' + mkdir -p $out/share/grafana + 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 { }; + }; + + meta = with lib; { + description = "Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB"; + license = licenses.agpl3Only; + homepage = "https://grafana.com"; + maintainers = with maintainers; [ offline fpletz willibutz globin ma27 Frostman ]; + platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + mainProgram = "grafana-server"; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/default.nix new file mode 100644 index 000000000000..95be470831c1 --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/default.nix @@ -0,0 +1,7 @@ +{ newScope, pkgs }: + +let + callPackage = newScope (pkgs // plugins); + plugins = import ./plugins.nix { inherit callPackage; }; +in + plugins diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/doitintl-bigquery-datasource/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/doitintl-bigquery-datasource/default.nix new file mode 100644 index 000000000000..aa8520e69b8e --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/doitintl-bigquery-datasource/default.nix @@ -0,0 +1,13 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "doitintl-bigquery-datasource"; + version = "2.0.3"; + zipHash = "sha256-QxUNRsO1ony+6tVdpwx3P/63XNIdAVIren6hUwChf9E="; + meta = with lib; { + description = "BigQuery DataSource for Grafana"; + license = licenses.mit; + maintainers = with maintainers; [ jwygoda ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafadruid-druid-datasource/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafadruid-druid-datasource/default.nix new file mode 100644 index 000000000000..a5ed12fbfa47 --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafadruid-druid-datasource/default.nix @@ -0,0 +1,13 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "grafadruid-druid-datasource"; + version = "1.4.1"; + zipHash = "sha256-7atxqRqKqop6ABQ+ead6wR/YRpJaV8j/Ri4VB9FXMu8="; + meta = with lib; { + description = "Connects Grafana to Druid"; + license = licenses.asl20; + maintainers = with maintainers; [ nukaduka ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-clickhouse-datasource/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-clickhouse-datasource/default.nix new file mode 100644 index 000000000000..355153937b43 --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-clickhouse-datasource/default.nix @@ -0,0 +1,19 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "grafana-clickhouse-datasource"; + version = "3.3.0"; + zipHash = { + x86_64-linux = "sha256-FkOX/2vPmLtxe/oOISldlVhayy7AwfFxLeiwJ5TNgYY="; + aarch64-linux = "sha256-4rCj+NaKPZbuVohlKmSf1M6n5ng9HZMrwzBCgLPdiok="; + x86_64-darwin = "sha256-bpey6EwwAqXgxjvjJ6ou4rinidHCpUr+Z89YpAZK7z8="; + aarch64-darwin = "sha256-u/U2lu4szf9JFt/zfhGmWKH2OUqpJDNaSI69EDdi1+w="; + }; + meta = with lib; { + description = "Connects Grafana to ClickHouse"; + license = licenses.asl20; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + maintainers = with maintainers; [ moody yuka ]; + platforms = attrNames zipHash; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-clock-panel/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-clock-panel/default.nix new file mode 100644 index 000000000000..61704eaaef34 --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-clock-panel/default.nix @@ -0,0 +1,13 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "grafana-clock-panel"; + version = "2.1.3"; + zipHash = "sha256-ZedeV/SQsBu55jAxFyyXQefir4hEl1/TQDmaTJN9bag="; + meta = with lib; { + description = "Clock panel for Grafana"; + license = licenses.mit; + maintainers = with maintainers; [ lukegb ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-piechart-panel/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-piechart-panel/default.nix new file mode 100644 index 000000000000..168295c64cd5 --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-piechart-panel/default.nix @@ -0,0 +1,13 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "grafana-piechart-panel"; + version = "1.6.4"; + zipHash = "sha256-bdAl3OmZgSNB+IxxlCb81abR+4dykKkRY3MpQUQyLks="; + meta = with lib; { + description = "Pie chart panel for Grafana"; + license = licenses.mit; + maintainers = with maintainers; [ lukegb ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix new file mode 100644 index 000000000000..57af5d265452 --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix @@ -0,0 +1,41 @@ +{ stdenvNoCC, fetchurl, unzip, lib }: + +{ pname, version, zipHash, meta ? {}, passthru ? {}, ... }@args: +let plat = stdenvNoCC.hostPlatform.system; in stdenvNoCC.mkDerivation ({ + inherit pname version; + + src = if lib.isAttrs zipHash then + fetchurl { + name = "${pname}-${version}-${plat}.zip"; + hash = zipHash.${plat} or (throw "Unsupported system: ${plat}"); + url = "https://grafana.com/api/plugins/${pname}/versions/${version}/download" + { + x86_64-linux = "?os=linux&arch=amd64"; + aarch64-linux = "?os=linux&arch=arm64"; + x86_64-darwin = "?os=darwin&arch=amd64"; + aarch64-darwin = "?os=darwin&arch=arm64"; + }.${plat} or (throw "Unsupported system: ${plat}"); + } + else + fetchurl { + name = "${pname}-${version}.zip"; + hash = zipHash; + url = "https://grafana.com/api/plugins/${pname}/versions/${version}/download"; + } + ; + + nativeBuildInputs = [ unzip ]; + + installPhase = '' + cp -R "." "$out" + chmod -R a-w "$out" + chmod u+w "$out" + ''; + + passthru = { + updateScript = [ ./update-grafana-plugin.sh pname ]; + } // passthru; + + meta = { + homepage = "https://grafana.com/grafana/plugins/${pname}"; + } // meta; +} // (builtins.removeAttrs args [ "zipHash" "pname" "version" "sha256" "meta" ])) diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-polystat-panel/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-polystat-panel/default.nix new file mode 100644 index 000000000000..ff06ec2137bd --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-polystat-panel/default.nix @@ -0,0 +1,13 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "grafana-polystat-panel"; + version = "2.1.4"; + zipHash = "sha256-15mi5NzbbWXJ/69VEwUS058atQ+z2g4C3T9/b+/Exwk="; + meta = with lib; { + description = "Hexagonal multi-stat panel for Grafana"; + license = licenses.asl20; + maintainers = with maintainers; [ lukegb ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-worldmap-panel/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-worldmap-panel/default.nix new file mode 100644 index 000000000000..630e5833667c --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-worldmap-panel/default.nix @@ -0,0 +1,13 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "grafana-worldmap-panel"; + version = "1.0.6"; + zipHash = "sha256-/lgsdBEL9HdJX1X1Qy0THBlYdUUI8SRtgF1Wig1Ktpk="; + meta = with lib; { + description = "World Map panel for Grafana"; + license = licenses.mit; + maintainers = with maintainers; [ lukegb ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/plugins.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/plugins.nix new file mode 100644 index 000000000000..8bbd738f7ab9 --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/plugins.nix @@ -0,0 +1,17 @@ +{ callPackage }: +{ + inherit callPackage; + + grafanaPlugin = callPackage ./grafana-plugin.nix { }; + + doitintl-bigquery-datasource = callPackage ./doitintl-bigquery-datasource { }; + grafadruid-druid-datasource = callPackage ./grafadruid-druid-datasource { }; + grafana-clickhouse-datasource = callPackage ./grafana-clickhouse-datasource { }; + grafana-clock-panel = callPackage ./grafana-clock-panel { }; + grafana-piechart-panel = callPackage ./grafana-piechart-panel { }; + grafana-polystat-panel = callPackage ./grafana-polystat-panel { }; + grafana-worldmap-panel = callPackage ./grafana-worldmap-panel { }; + redis-app = callPackage ./redis-app { }; + redis-datasource = callPackage ./redis-datasource { }; + redis-explorer-app = callPackage ./redis-explorer-app { }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/redis-app/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/redis-app/default.nix new file mode 100644 index 000000000000..f3dedc247bdb --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/redis-app/default.nix @@ -0,0 +1,13 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "redis-app"; + version = "2.2.1"; + zipHash = "sha256-1ZzJaGhlM6CaTecj69aqJ9fqN7wYSsiDCMTRVkZJUb0="; + meta = with lib; { + description = "Redis Application plugin for Grafana"; + license = licenses.asl20; + maintainers = with maintainers; [ azahi ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/redis-datasource/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/redis-datasource/default.nix new file mode 100644 index 000000000000..4d21fe4fffec --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/redis-datasource/default.nix @@ -0,0 +1,13 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "redis-datasource"; + version = "2.2.0"; + zipHash = "sha256-a4at8o185XSOyNxZZKfb0/j1CVoKQ9JZx0ofoPUBqKs="; + meta = with lib; { + description = "Redis Data Source for Grafana"; + license = licenses.asl20; + maintainers = with maintainers; [ azahi ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/redis-explorer-app/default.nix b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/redis-explorer-app/default.nix new file mode 100644 index 000000000000..e58da0bebd83 --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/redis-explorer-app/default.nix @@ -0,0 +1,13 @@ +{ grafanaPlugin, lib }: + +grafanaPlugin rec { + pname = "redis-explorer-app"; + version = "2.1.1"; + zipHash = "sha256-t5L9XURNcswDbZWSmehs/JYU7NoEwhX1If7ghbi509g="; + meta = with lib; { + description = "Redis Explorer plugin for Grafana"; + license = licenses.asl20; + maintainers = with maintainers; [ azahi ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/servers/monitoring/grafana/plugins/update-grafana-plugin.sh b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/update-grafana-plugin.sh new file mode 100755 index 000000000000..dd8f050c633c --- /dev/null +++ b/nixpkgs/pkgs/servers/monitoring/grafana/plugins/update-grafana-plugin.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl jq common-updater-scripts + +set -eu -o pipefail + +readonly plugin_name="$1" +readonly latest_version="$(curl "https://grafana.com/api/plugins/${plugin_name}" | jq -r .version)" +update-source-version "grafanaPlugins.${plugin_name}" "$latest_version" |