From ba1029a81a9e3e56909fb660c721a7357b4905c8 Mon Sep 17 00:00:00 2001 From: Benjamin Kober Date: Sun, 3 Oct 2021 18:59:02 +0200 Subject: [PATCH] Submit/fix vega lite (#139876) Co-authored-by: Sandro Co-authored-by: Benjamin Kober --- pkgs/development/node-packages/default.nix | 21 ++++++++-------- .../node-packages/package-tests/vega-lite.nix | 24 +++++++++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 pkgs/development/node-packages/package-tests/vega-lite.nix diff --git a/pkgs/development/node-packages/default.nix b/pkgs/development/node-packages/default.nix index 159625810bf0..db1312b5ccec 100644 --- a/pkgs/development/node-packages/default.nix +++ b/pkgs/development/node-packages/default.nix @@ -387,18 +387,19 @@ let }; vega-lite = super.vega-lite.override { - # npx tries to install vega from scratch at vegalite runtime if it - # can't find it. We thus replace it with a direct call to the nix - # derivation. This might not be necessary anymore in future vl - # versions: https://github.com/vega/vega-lite/issues/6863. postInstall = '' - substituteInPlace $out/lib/node_modules/vega-lite/bin/vl2pdf \ - --replace "npx -p vega vg2pdf" "${self.vega-cli}/bin/vg2pdf" - substituteInPlace $out/lib/node_modules/vega-lite/bin/vl2svg \ - --replace "npx -p vega vg2svg" "${self.vega-cli}/bin/vg2svg" - substituteInPlace $out/lib/node_modules/vega-lite/bin/vl2png \ - --replace "npx -p vega vg2png" "${self.vega-cli}/bin/vg2png" + cd node_modules + for dep in ${self.vega-cli}/lib/node_modules/vega-cli/node_modules/*; do + if [[ ! -d $dep ]]; then + ln -s "${self.vega-cli}/lib/node_modules/vega-cli/node_modules/$dep" + fi + done ''; + passthru.tests = { + simple-execution = pkgs.callPackage ./package-tests/vega-lite.nix { + inherit (self) vega-lite; + }; + }; }; webtorrent-cli = super.webtorrent-cli.override { diff --git a/pkgs/development/node-packages/package-tests/vega-lite.nix b/pkgs/development/node-packages/package-tests/vega-lite.nix new file mode 100644 index 000000000000..5be356f0683f --- /dev/null +++ b/pkgs/development/node-packages/package-tests/vega-lite.nix @@ -0,0 +1,24 @@ +{ runCommand, vega-lite }: + +let + inherit (vega-lite) packageName version; +in + +runCommand "${packageName}-tests" { meta.timeout = 60; } + '' + # get version of installed program and compare with package version + claimed_version="$(${vega-lite}/bin/vl2vg --version)" + if [[ "$claimed_version" != "${version}" ]]; then + echo "Error: program version does not match package version ($claimed_version != ${version})" + exit 1 + fi + + # run dummy commands + ${vega-lite}/bin/vl2vg --help > /dev/null + ${vega-lite}/bin/vl2svg --help > /dev/null + ${vega-lite}/bin/vl2png --help > /dev/null + ${vega-lite}/bin/vl2pdf --help > /dev/null + + # needed for Nix to register the command as successful + touch $out + ''