2022-02-18 17:41:59 +01:00
|
|
|
{ lib, mkYarnPackage, fetchFromGitHub, nodejs, runtimeShell
|
|
|
|
, nodePackages, python3, vips, glib, pkg-config
|
|
|
|
}:
|
2020-12-23 17:36:05 +01:00
|
|
|
|
|
|
|
# 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`.
|
2021-10-09 20:51:00 +02:00
|
|
|
# * Regenerate `yarn.lock` and `yarn2nix --no-patch`.
|
2020-12-23 17:36:05 +01:00
|
|
|
# * Replace new `package.json`, `yarn.nix`, `yarn.lock` here.
|
|
|
|
# * Update `version`+`hash` and rebuild.
|
|
|
|
|
|
|
|
mkYarnPackage rec {
|
2021-07-25 23:53:02 +02:00
|
|
|
pname = "grafana-image-renderer";
|
2022-02-18 17:41:59 +01:00
|
|
|
version = "3.4.0";
|
2020-12-23 17:36:05 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "grafana";
|
|
|
|
repo = "grafana-image-renderer";
|
2021-03-07 22:56:28 +01:00
|
|
|
rev = "v${version}";
|
2022-02-18 17:41:59 +01:00
|
|
|
sha256 = "sha256-6yw+zp83T6VVa4A9KYX6rzMKG5GoyJ7M8Z+cEHE4uts=";
|
2020-12-23 17:36:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
pushd deps/renderer
|
|
|
|
npm run build
|
|
|
|
popd
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontInstall = true;
|
|
|
|
|
|
|
|
packageJSON = ./package.json;
|
|
|
|
yarnNix = ./yarn.nix;
|
|
|
|
yarnLock = ./yarn.lock;
|
|
|
|
|
2022-02-18 17:41:59 +01:00
|
|
|
pkgConfig.sharp = {
|
|
|
|
nativeBuildInputs = [ nodePackages.node-gyp python3 pkg-config ];
|
|
|
|
buildInputs = [ glib vips ];
|
|
|
|
postInstall = ''
|
|
|
|
node-gyp rebuild
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-12-23 17:36:05 +01:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|