Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nodePackages vega-cli and vega-lite #97908

Merged
merged 4 commits into from Sep 19, 2020
Merged

Conversation

MMesch
Copy link
Contributor

@MMesch MMesch commented Sep 13, 2020

Motivation for this change

Adds the vega and the vega-lite command line tools for plotting. This means the binaries:

vg2svg
vg2pdf
vg2png
vl2vg
vl2pdf
vl2svg
vl2png

Vegalite required substituting some lines that call npx to install vega on the fly. Maybe there is a better solution. I tested these tools with:

nix-shell --pure -I nixpkgs=./nixpkgs -p busybox -p nodePackages.vega-cli --command "wget -O - https://vega.github.io/vega/examples/bar-chart.vg.json | vg2png > vega-cli-test.png"
nix-shell --pure -I nixpkgs=./nixpkgs -p busybox -p nodePackages.vega-lite --command "wget -O - https://raw.githubusercontent.com/vega/vega-lite/master/examples/specs/bar.vl.json | vl2png > vega-lite-test.png"
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@MMesch
Copy link
Contributor Author

MMesch commented Sep 14, 2020

I tried to run nixpkgs-review pr --post-result 97908 and stopped it after 2h because I needed the CPU. It somehow seems to hang on twemoji, mojione and sagedoc. inkscape also somehow appears there. The output that I got until then is:

$ git -c fetch.prune=false fetch --force https://github.com/NixOS/nixpkgs master:refs/nixpkgs-review/0 pull/97908/head:refs/nixpkgs-review/1
$ git worktree add /home/matto/.cache/nixpkgs-review/pr-97908-1/nixpkgs 24fa210e772351f118e5f56e5acbe5eaea38a95f
Preparing worktree (detached HEAD 24fa210e772)
Updating files: 100% (22686/22686), done.
HEAD is now at 24fa210e772 rclone: 1.53.0 -> 1.53.1 (#97953)
$ nix-env -f /home/matto/.cache/nixpkgs-review/pr-97908-1/nixpkgs -qaP --xml --out-path --show-trace
$ git merge --no-commit 690fffccf47b4561013912dd37d5bda8ea8484b7
Automatic merge went well; stopped before committing as requested
$ nix-env -f /home/matto/.cache/nixpkgs-review/pr-97908-1/nixpkgs -qaP --xml --out-path --show-trace --meta
39 packages updated:
bitwarden-cli emojione etcher image_optim lumo node_castnow node_create-cycle-app node_imapnotify joplin (1.0.166 → 1.0.167) node_mirakurun netlify-cli (2.61.0 → 2.62.0) node_redoc-cli node_thelounge node_triton node__at_antora_slash_cli node__at_webassemblyjs_slash_wasm-text-gen parity-ui ripcord sage sage sage slack slack twemoji-color-font vimPlugins.coc-css (1.2.4 → 1.2.5) vimPlugins.coc-eslint (1.2.7 → 1.3.0) vimPlugins.coc-git (1.8.3 → 2.0.0) vimPlugins.coc-go (0.10.0 → 0.11.0) vimPlugins.coc-highlight (1.2.5 → 1.2.6) vimPlugins.coc-jest (1.0.3 → 1.0.4) vimPlugins.coc-json (1.2.6 → 1.3.0) vimPlugins.coc-metals (0.9.2 → 0.9.3) vimplugin-coc-prettier vimPlugins.coc-r-lsp (1.1.1 → 1.2.0) vimPlugins.coc-snippets (2.1.28 → 2.2.0) vimPlugins.coc-solargraph (1.1.6 → 1.1.7) vimplugin-coc-stylelint vimPlugins.coc-tsserver (1.5.5 → 1.5.6) vimPlugins.coc-vetur (1.1.12 → 1.1.13)

$ nix build --no-link --keep-going --option build-use-sandbox relaxed -f /home/matto/.cache/nixpkgs-review/pr-97908-1/build.nix
builder for '/nix/store/b42m79dxaz44gjb4gpg3mmlwdr4zxy4h-node_joplin-1.0.167.drv' failed with exit code 1; last 10 log lines:
  npm ERR! errno 1
  npm ERR! keytar@5.6.0 install: `prebuild-install || node-gyp rebuild`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the keytar@5.6.0 install script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /build/.npm/_logs/2020-09-14T08_13_48_980Z-debug.log
 [...]

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/299

@doronbehar
Copy link
Contributor

@MMesch It's almost impossible to merge changes to node packages, unfortunately. Could you please fix them and ping me when you are ready? Preferably, git add all the files (don't use --patch to select only the changes relevant to you). I promise I'll merge it before there are merge conflicts.

Once that'll be done, I'd be happy to get your help on #96961 .

@MMesch
Copy link
Contributor Author

MMesch commented Sep 16, 2020

Hi @doronbehar

It's almost impossible to merge changes to node packages, unfortunately

What do you mean with this? Is it possible or not? I looked on your PR and saw that you suggested generating nix expressions for the packages you want to add independently. I have done that equally for vega-cli and vega-lite on my machine. Do you think it would be better to move forward like this?

Also, I already added git add everything! Are there files that you are missing?

@doronbehar
Copy link
Contributor

What do you mean with this?

I mean that as a contributor, with no merge permissions, it's impossible to put out a PR, and when the time comes for a committer to merge it, the PR has no merge conflicts.

I have done that equally for vega-cli and vega-lite on my machine. Do you think it would be better to move forward like this?

It depends on you. For balena-cli, I realized at a certain point I have to do it because their releases are too frequent for node packages' generate.sh. If you'd like to have more influence upon it, I'd suggest to make it have it's own set of generated nix expressions. Plus, for sure you'd probably won't encounter merge conflicts with the generated expressions.

@doronbehar
Copy link
Contributor

Are there files that you are missing?

I don't think so, but I haven't checked.

@MMesch
Copy link
Contributor Author

MMesch commented Sep 18, 2020

@doronbehar I have rebased and regenerated node-packages.nix for the two relevant commits. Maybe I didn't understand if you wanted to do anything else. Let me know!

In case there are conflicts again, this can be rebased from the nodePackages folder with:

git fetch
git rebase origin/master
git checkout --theirs node-packages.nix
./generate.sh
git add .
git rebase --continue
git checkout --theirs node-packages.nix
./generate.sh
git add .
git rebase --continue

(takes ~2h on my machine)

@MMesch
Copy link
Contributor Author

MMesch commented Sep 19, 2020 via email

@doronbehar
Copy link
Contributor

You should be able to spare yourself running ./generate.sh, but you should need rewriting history a bit.

@MMesch
Copy link
Contributor Author

MMesch commented Sep 19, 2020

I hope it's ok now @doronbehar . I ran the vega-cli and vega-lite tests that I posted above and they work.

pkgs/development/node-packages/default.nix Outdated Show resolved Hide resolved
pkgs/development/node-packages/default.nix Outdated Show resolved Hide resolved
@MMesch MMesch force-pushed the mmesch/vega branch 3 times, most recently from 773aa67 to ae9af63 Compare September 19, 2020 13:05
@MMesch
Copy link
Contributor Author

MMesch commented Sep 19, 2020

Sorry for the formatting issues. How about now @doronbehar ?

Comment on lines 190 to 196
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"
'';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"
'';
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"
'';

Sorry for the nitpick, but it should be perfect now!

@doronbehar
Copy link
Contributor

@MMesch after fixing once more the indentation, please apply this patch:

diff --git i/pkgs/development/node-packages/default.nix w/pkgs/development/node-packages/default.nix
index 71b9bd77411..8d8d9fc89ae 100644
--- i/pkgs/development/node-packages/default.nix
+++ w/pkgs/development/node-packages/default.nix
@@ -181,6 +181,8 @@ let
         # https://sharp.pixelplumbing.com/install
         vips
 
+        libsecret
+        self.node-gyp-build
         self.node-pre-gyp
       ];
     };

And commit it as: joplin: fix build by adding libsecret and node-gyp-build.

It's not related to your PR, but these are new deps that your update to all of node packages require - since you ran ./generate.sh.

@MMesch
Copy link
Contributor Author

MMesch commented Sep 19, 2020 via email

Co-authored-by: Doron Behar <doron.behar@gmail.com>
@MMesch
Copy link
Contributor Author

MMesch commented Sep 20, 2020

Many thanks for you help @doronbehar . How can I help with your PR?

@doronbehar
Copy link
Contributor

TBH I only want someone to approve it for the record, and verify that it works. And comments upon meta data or such would be welcome #96961 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants