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: include the asciidoctor-epub3 gem #64298

Merged
merged 5 commits into from Jul 4, 2019

Conversation

michaelpj
Copy link
Contributor

Motivation for this change

This is another common output format for asciidoctor, and this gem is at least semi-official (maintained by the asciidoctor maintainer).

Things done

The first commit does some cleaning, by allowing us to use the default gem config in nixpkgs. We need this in the second commit as it makes nokogiri work. We could combine the configs properly, but it seems better to put our configuration for the mathematical gem centrally in case other people need to use it.

I also had to change how the update script works, but I think it's reasonable still.

The second commit actually adds the asciidoctor-epub3 gem. I've tested that this does actually work thereafter.

cc @worldofpeace @danbst who've looked at asciidoctor changes recently.

  • 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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

This has two benefits:
- Anyone else using the `mathematical` gem will benefit from the config.
- The gem config overrides the default one, so we were losing the fixes
for other gems.

I had to change how the update script works. Now it looks at the `gems`
passthru from `bundlerApp`.
This is another common output target for asciidctor that requires an
additional gem.

The previous commit is necessary for this to work, so that we get the
gem config for nokogiri correctly.
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
rm gemset.nix Gemfile.lock
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we do this before building the shell then we can't build the shell!

Copy link
Member

Choose a reason for hiding this comment

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

Agreed! The more general issue is that the updater script is depending on the project to be working. So as soon as it breaks it becomes harder to repair it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see a way to avoid this while still piggybacking off the app definition to get all the dependencies....

Copy link
Contributor

Choose a reason for hiding this comment

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

🤦‍♂️ probably I was running a nix-shell inside nix-shell... I wish there was bundix --force-update

pkgs/tools/typesetting/asciidoctor/default.nix Outdated Show resolved Hide resolved
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
rm gemset.nix Gemfile.lock
Copy link
Member

Choose a reason for hiding this comment

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

Agreed! The more general issue is that the updater script is depending on the project to be working. So as soon as it breaks it becomes harder to repair it.

};
}
in app.overrideAttrs (attrs: { passthru = attrs.passthru // { updateShell = shell; }; })
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
in app.overrideAttrs (attrs: { passthru = attrs.passthru // { updateShell = shell; }; })
in app

attach the shell directly on the app.passthru to avoid the overhead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't work as app.gems isn't defined then.

Copy link
Member

Choose a reason for hiding this comment

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

I pushed f726160 which demonstrates how to implement it. The key is that nix is a lazily-evaluated language.

pkgs/tools/typesetting/asciidoctor/default.nix Outdated Show resolved Hide resolved
@michaelpj
Copy link
Contributor Author

Also I've realised that I may want to include the epubcheck and kindlegen gems, since they don't seem to be properly included by default. Some bundler fanciness in the asciidoctor Gemfile. Investigating....

@michaelpj
Copy link
Contributor Author

Comments addressed.

I've opted not to include the epubcheck and kindlegen dependencies. They're a bit dodgy, e.g. kindlegen just curls the binary from the internet and provides it. Even better, the paths to the epubcheck and kindlegen tools can just be given by environment variables, so there's no need to use the dodgy gems.

@michaelpj
Copy link
Contributor Author

Actually, given the environment variables work, I can just wrap the executable. The remaining annoyance is that kindlegen is unfree. I guess I could gate that behind withKindlegen? What's the usual approach for optional unfree deps?

kindlegen is unfree, so we don't include it by default. The derivation
can be overridden to include it.
@michaelpj
Copy link
Contributor Author

Okay, I wrapped the executable and that works nicely. I've put something in so epubcheck and kindlegen are optional, with kindlegen being off by default due to being unfree. But if there's a more standard way, happy to use that.

};
}
in app.overrideAttrs (attrs: { passthru = attrs.passthru // { updateShell = shell; }; })
Copy link
Member

Choose a reason for hiding this comment

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

I pushed f726160 which demonstrates how to implement it. The key is that nix is a lazily-evaluated language.

@michaelpj
Copy link
Contributor Author

Nice, thanks.

@zimbatm
Copy link
Member

zimbatm commented Jul 4, 2019

@michaelpj let me know if you agree with my changes, if yes I will merge the PR.

@michaelpj
Copy link
Contributor Author

Yes, they're good!

@zimbatm zimbatm merged commit a0f5348 into NixOS:master Jul 4, 2019
@lopsided98
Copy link
Contributor

This had the effect of breaking the default NixOS configuration on armv6l and armv7l, because it pulls Java into the build-time closure through epubcheck. Java has been broken on these platforms for quite a while, and this PR simply made the issue obvious.

On the other hand, this is the only usage of Java in a basic NixOS system, and pulls in many other dependencies (at build time, so binary cache users are not affected), so I am wondering if we want to disable epubcheck by default. I can't decide whether this is a good idea, or if we are better having a more fully featured package. Is there any specific use-case that needs epubcheck?

@michaelpj
Copy link
Contributor Author

Hm, I'd assumed that Java would be an unproblematic package! I also didn't know the default configuration depended on this (why? the manual?).

I think disabling epubcheck would be fine. Alternatively, we could override it to disable epubcheck at the use site which is problematic, e.g. where the manual uses it if that's the problem.

@lopsided98
Copy link
Contributor

The dependency chain is: udisks -> libblockdev -> libndctl -> asciidoctor

@zimbatm
Copy link
Member

zimbatm commented Jul 18, 2019

@michaelpj: can you send a PR to disable epubcheck please?

@michaelpj
Copy link
Contributor Author

@zimbatm #65018

@lopsided98
Copy link
Contributor

I'm working on fixing Java on ARM as well, and should have a PR by this weekend.

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

4 participants