nixpkgs/pkgs/servers/monitoring/grafana-image-renderer/default.nix
Maximilian Bosch a9d0682475
grafana-image-renderer: init at 2020-12-01
This package[1] is a replacement for the old phantomjs-integration[2]
which is practically EOL. It is basically used to render PNGs of panels
that triggered an alert in Grafana.

This package internally uses `puppeteer`[3] to control a headless
Chromium instance. Even though puppeteer recommends to use a fixed
revision of `chromium`, I checked that our default `pkgs.chromium` works
fine as well. Also, I don't think it's a good idea to use outdated
browser versions[4].

I used the latest revision from `master` on purpose since compiling the
code with `tsc` from `v2.0` didn't work and I couldn't figure out why.

[1] https://grafana.com/grafana/plugins/grafana-image-renderer
[2] https://grafana.com/blog/2020/05/07/grafana-7.0-preview-new-image-renderer-plugin-to-replace-phantomjs/
[3] https://github.com/puppeteer/puppeteer
[4] currently, puppeteer v2.0.0 is used which recommends revision 706915
    (v79.0.3945.130).
2021-01-01 19:19:11 +01:00

68 lines
1.7 KiB
Nix

{ lib, mkYarnPackage, fetchFromGitHub, nodejs, runtimeShell }:
# Notes for the upgrade:
# * Download the tarball of the new version to use.
# * Remove the `resolutions`-section from upstream `package.json`
# as this breaks with `yarn2nix`.
# * Regenerate `yarn.lock` and `yarn2nix`.
# * Replace new `package.json`, `yarn.nix`, `yarn.lock` here.
# * Update `version`+`hash` and rebuild.
mkYarnPackage rec {
name = "grafana-image-renderer-unstable";
version = "2020-12-01";
src = fetchFromGitHub {
owner = "grafana";
repo = "grafana-image-renderer";
rev = "ce1f81438e5f69c7fd7c73ce08bab624c4c92e25";
sha256 = "sha256-1Ke1KLLNZ1dkLH0BWB60r2c45RBbndd0eepjc0nlHVk=";
};
buildPhase = ''
runHook preBuild
pushd deps/renderer
npm run build
popd
runHook postBuild
'';
dontInstall = true;
packageJSON = ./package.json;
yarnNix = ./yarn.nix;
yarnLock = ./yarn.lock;
distPhase = ''
runHook preDist
shopt -s extglob
pushd deps/renderer
install_path="$out/libexec/grafana-image-renderer"
mkdir -p $install_path
cp -R ../../node_modules $install_path
cp -R ./!(node_modules) $install_path
popd
mkdir -p $out/bin
cat >$out/bin/grafana-image-renderer <<EOF
#! ${runtimeShell}
${nodejs}/bin/node $install_path/build/app.js \$@
EOF
chmod +x $out/bin/grafana-image-renderer
runHook postDist
'';
meta = with lib; {
homepage = "https://github.com/grafana/grafana-image-renderer";
description = "A Grafana backend plugin that handles rendering of panels & dashboards to PNGs using headless browser (Chromium/Chrome)";
license = licenses.asl20;
maintainers = with maintainers; [ ma27 ];
platforms = platforms.linux;
};
}