2022-06-16 17:23:12 +00:00
|
|
|
{ lib, buildGoModule, fetchurl, fetchFromGitHub, nixosTests, tzdata, wire }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
buildGoModule rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "grafana";
|
2022-07-18 16:21:45 +00:00
|
|
|
version = "9.0.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
excludedPackages = [ "alert_webhook_listener" "clean-swagger" "release_publisher" "slow_proxy" "slow_proxy_mac" "macaron" "devenv" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
rev = "v${version}";
|
|
|
|
owner = "grafana";
|
|
|
|
repo = "grafana";
|
2022-07-18 16:21:45 +00:00
|
|
|
sha256 = "sha256-oFVAiQt+ZxLB1On1wKM2R2qTEl5zBbWpkvBOLQ081+A=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
srcStatic = fetchurl {
|
|
|
|
url = "https://dl.grafana.com/oss/release/grafana-${version}.linux-amd64.tar.gz";
|
2022-07-18 16:21:45 +00:00
|
|
|
sha256 = "sha256-l2XTC0OxIeUD4sjM4w9WsT9s5akGjWpFmnZnmI/vSEA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
vendorSha256 = "sha256-ncMIu6J7D3xflZSxf8txpaQd0YW62CtzcO5w/PUE1UU=";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ wire ];
|
2020-05-29 06:06:01 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
preBuild = ''
|
2021-12-06 16:07:01 +00:00
|
|
|
# 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
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
go generate ./pkg/framework/coremodel
|
|
|
|
go generate ./public/app/plugins
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
# The testcase makes an API call against grafana.com:
|
|
|
|
#
|
2021-12-06 16:07:01 +00:00
|
|
|
# [...]
|
|
|
|
# grafana> t=2021-12-02T14:24:58+0000 lvl=dbug msg="Failed to get latest.json repo from github.com" logger=update.checker error="Get \"https://raw.githubusercontent.com/grafana/grafana/main/latest.json\": dial tcp: lookup raw.githubusercontent.com on [::1]:53: read udp [::1]:36391->[::1]:53: read: connection refused"
|
|
|
|
# grafana> t=2021-12-02T14:24:58+0000 lvl=dbug msg="Failed to get plugins repo from grafana.com" logger=plugin.manager error="Get \"https://grafana.com/api/plugins/versioncheck?slugIn=&grafanaVersion=\": dial tcp: lookup grafana.com on [::1]:53: read udp [::1]:41796->[::1]:53: read: connection refused"
|
|
|
|
sed -i -e '/Request is not forbidden if from an admin/a t.Skip();' pkg/tests/api/plugins/api_plugins_test.go
|
2021-06-28 23:13:55 +00:00
|
|
|
|
|
|
|
# Skip a flaky test (https://github.com/NixOS/nixpkgs/pull/126928#issuecomment-861424128)
|
|
|
|
sed -i -e '/it should change folder successfully and return correct result/{N;s/$/\nt.Skip();/}'\
|
|
|
|
pkg/services/libraryelements/libraryelements_patch_test.go
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
|
|
|
|
# main module (github.com/grafana/grafana) does not contain package github.com/grafana/grafana/scripts/go
|
|
|
|
rm -r scripts/go
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-27 14:25:00 +00:00
|
|
|
ldflags = [
|
|
|
|
"-s" "-w" "-X main.version=${version}"
|
|
|
|
];
|
2020-10-07 09:15:18 +00:00
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
|
|
|
tar -xvf $srcStatic
|
2020-05-15 21:57:56 +00:00
|
|
|
mkdir -p $out/share/grafana
|
|
|
|
mv grafana-*/{public,conf,tools} $out/share/grafana/
|
2021-12-21 02:18:32 +00:00
|
|
|
|
|
|
|
cp ./conf/defaults.ini $out/share/grafana/conf/
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
passthru = {
|
|
|
|
tests = { inherit (nixosTests) grafana; };
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB";
|
2021-06-28 23:13:55 +00:00
|
|
|
license = licenses.agpl3;
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://grafana.com";
|
|
|
|
maintainers = with maintainers; [ offline fpletz willibutz globin ma27 Frostman ];
|
2021-09-18 10:52:07 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
|
|
mainProgram = "grafana-server";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|