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

asciidoctor: add rouge to dependencies #63689

Merged
merged 2 commits into from Jun 26, 2019

Conversation

svalaskevicius
Copy link
Contributor

@svalaskevicius svalaskevicius commented Jun 23, 2019

Motivation for this change

Add syntax highlighting support via rouge.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nix-review --run "nix-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)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@@ -0,0 +1,3 @@
Rebuild gemset.nix and Gemfile.lock with:
Copy link
Contributor

Choose a reason for hiding this comment

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

offtopic: to be pedantic, you should use .adoc here =)

@danbst
Copy link
Contributor

danbst commented Jun 23, 2019

I like that README is added (I've had this chicken-and-egg problem with gemset.nix). However I think it is enough to do:

$ nix-shell -p bundix --run 'bundix'

to rebuild gemset.nix.

Also, why should we add rouge? There already is 'coderay', 'pygments.rb'. Which benefits has rouge compared to those?

@svalaskevicius
Copy link
Contributor Author

I've tried pygments a while back with asciidoctor and it just didn't work.. Found this to be an easy workaround for what I needed instead of debugging pygments (or maybe failure to use it?)

On a more global scale, adding it here costs little and gives users more choice what to use

@svalaskevicius
Copy link
Contributor Author

svalaskevicius commented Jun 23, 2019

Regarding bundix, I've added nix-shell to be able to regenerate it without having the package installed.. As I stumbled on it a few times - otherwise it fails on missing dependencies.

@danbst
Copy link
Contributor

danbst commented Jun 23, 2019

As I stumbled on it a few times - otherwise it fails on missing dependencies.

I've tried rm gemset.nix && nix-shell --pure -p bundix --run 'bundix' and it was enough to regenerate gemset.nix. The rebuild-gemset.nix is redundant here, just mention the command I've proposed in README.adoc.

On a more global scale, adding it here costs little and gives users more choice what to use

Ok. I don't know Ruby packaging details, I'm curious how it behaves when I use asciidoctor and rouge in local Gemfile/gemset.nix. I hope there will be no conflicts.

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
# TODO: how to reuse the list from default.nix?
buildInputs = with pkgs; [
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd think with #62971 this would be unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, not quite sure what you mean :) do you mean this file, or this list here? (I'm still rather new to nix language, and inter-module dependency handling)

any chance you could update the PR to the preferred approach? (I think I checked that GH checkbox allowing maintainer updates)

please also see my other comment on the PR where I failed to generate the gemset and Gemfile.lock in any other approach I've tried...

@svalaskevicius
Copy link
Contributor Author

Thanks, I'll try reproducing the dependencies error when regenerating. Will report back here when done. Will update readme too.

@danbst
Copy link
Contributor

danbst commented Jun 25, 2019

@svalaskevicius have you reproduced the issue?

@svalaskevicius
Copy link
Contributor Author

Sorry didn't have a chance yet. Will try to do it this evening :)

@svalaskevicius
Copy link
Contributor Author

ok, reproduced, (@danbst)

your command works ok only if Gemfile.lock is present, however, it doesn't add new libs to it, only converts the lock file to gemset.nix.

to add rouge to the lock file, one apparently needs to run bundix -m, which runs ruby things.. that fail to install mathematical because there are no binary dependencies installed:

<compiling things and dep errors>
An error occurred while installing mathematical (1.6.12), and Bundler cannot continue.
Make sure that `gem install mathematical -v '1.6.12' --source 'https://rubygems.org/'` succeeds before bundling.                                                             

Thus, I still don't see any other alternative rather than in this PR.

I'll update the readme to adoc though :)

@svalaskevicius
Copy link
Contributor Author

svalaskevicius commented Jun 25, 2019

done. also when testing now I noticed that rouge and some other dep have upped their version

@danbst
Copy link
Contributor

danbst commented Jun 26, 2019

@svalaskevicius thanks! Makes sense. I found a way to remove duplication. Here's diff:

diff --git a/pkgs/tools/typesetting/asciidoctor/default.nix b/pkgs/tools/typesetting/asciidoctor/default.nix
index 9508f3ff023..e46ebcf18ae 100644
--- a/pkgs/tools/typesetting/asciidoctor/default.nix
+++ b/pkgs/tools/typesetting/asciidoctor/default.nix
@@ -1,10 +1,10 @@
-{ stdenv, lib, bundlerApp, ruby
+{ stdenv, lib, bundlerApp, ruby, bundix, mkShell
   # Dependencies of the 'mathematical' package
 , cmake, bison, flex, glib, pkgconfig, cairo
 , pango, gdk_pixbuf, libxml2, python3, patchelf
 }:
 
-bundlerApp {
+bundlerApp rec {
   inherit ruby;
   pname = "asciidoctor";
   gemdir = ./.;
@@ -43,6 +43,12 @@ bundlerApp {
     };
   };
 
+  passthru.updateShell = mkShell {
+    buildInputs = (gemConfig.mathematical {}).buildInputs ++ [
+      bundix
+    ];
+  };
+
   meta = with lib; {
     description = "A faster Asciidoc processor written in Ruby";
     homepage = http://asciidoctor.org/;
diff --git a/pkgs/tools/typesetting/asciidoctor/update.sh b/pkgs/tools/typesetting/asciidoctor/update.sh
new file mode 100755
index 00000000000..10a053a847b
--- /dev/null
+++ b/pkgs/tools/typesetting/asciidoctor/update.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+rm gemset.nix Gemfile.lock
+nix-shell ../../../.. -A asciidoctor.updateShell --run '
+  bundix -m --bundle-pack-path $TMPDIR/asciidoctor-ruby-bundle
+'
+rm -r .bundle
\ No newline at end of file

That can also remove the need for README, as update.sh is kinda standard way for package update scripts.

If you like it, you may embed it into this PR. Otherwise I can push it separately.

@svalaskevicius
Copy link
Contributor Author

Thanks! I'll test and add it a bit later :)

@svalaskevicius
Copy link
Contributor Author

works well! I've set you as the author in the commit @danbst if it's ok with you :)

@danbst danbst merged commit b8796d6 into NixOS:master Jun 26, 2019
@danbst
Copy link
Contributor

danbst commented Jun 26, 2019

@svalaskevicius thanks for doublechecking!

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