nixpkgs/pkgs/servers/monitoring/grafana/default.nix
2020-03-19 11:54:51 -07:00

46 lines
1.4 KiB
Nix

{ lib, buildGoPackage, fetchurl, fetchFromGitHub, phantomJsSupport ? false, phantomjs2 ? null }:
buildGoPackage rec {
pname = "grafana";
version = "6.7.0";
goPackagePath = "github.com/grafana/grafana";
excludedPackages = [ "release_publisher" ];
src = fetchFromGitHub {
rev = "v${version}";
owner = "grafana";
repo = "grafana";
sha256 = "013586kaiyrs5b1mxf9vlcfh7va8md5amnh2jj26jph8ns6m0f87";
};
srcStatic = fetchurl {
url = "https://dl.grafana.com/oss/release/grafana-${version}.linux-amd64.tar.gz";
sha256 = "05g6lsl0vmc4q60dkm1404dl0k3wrlf6yy2l2cnaydl6aqz1kh8d";
};
postPatch = ''
substituteInPlace pkg/cmd/grafana-server/main.go \
--replace 'var version = "5.0.0"' 'var version = "${version}"'
'';
preBuild = "export GOPATH=$GOPATH:$NIX_BUILD_TOP/go/src/${goPackagePath}/Godeps/_workspace";
postInstall = ''
tar -xvf $srcStatic
mkdir -p $bin/share/grafana
mv grafana-*/{public,conf,tools} $bin/share/grafana/
'' + lib.optionalString phantomJsSupport ''
ln -sf ${phantomjs2}/bin/phantomjs $bin/share/grafana/tools/phantomjs/phantomjs
'';
meta = with lib; {
description = "Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB";
license = licenses.asl20;
homepage = "https://grafana.com";
maintainers = with maintainers; [ offline fpletz willibutz globin ma27 ];
platforms = platforms.linux;
};
}