{ lib, buildGoModule, fetchurl, fetchFromGitHub, nixosTests }: buildGoModule rec { pname = "grafana"; version = "7.4.3"; excludedPackages = [ "release_publisher" ]; src = fetchFromGitHub { rev = "v${version}"; owner = "grafana"; repo = "grafana"; sha256 = "sha256-FPQa6q1ks9Lpod5sI29YBnGZvVRU12hTiw6GR85/mEs="; }; srcStatic = fetchurl { url = "https://dl.grafana.com/oss/release/grafana-${version}.linux-amd64.tar.gz"; sha256 = "sha256-idbG+K9NVnNhEB0f7DfP7iaEnHMf59ieQtYnmT6CvVM="; }; vendorSha256 = "sha256-LL+EkDZbbaNo/fPMGlPsB8jgBYHoe6SdkBbQoW5y4EU="; postPatch = '' substituteInPlace pkg/cmd/grafana-server/main.go \ --replace 'var version = "5.0.0"' 'var version = "${version}"' ''; # main module (github.com/grafana/grafana) does not contain package github.com/grafana/grafana/scripts/go # main module (github.com/grafana/grafana) does not contain package github.com/grafana/grafana/dashboard-schemas preBuild = '' rm -r dashboard-schemas scripts/go ''; postInstall = '' tar -xvf $srcStatic mkdir -p $out/share/grafana mv grafana-*/{public,conf,tools} $out/share/grafana/ ''; passthru.tests = { inherit (nixosTests) grafana; }; 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 Frostman ]; platforms = platforms.linux; }; }