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

uberwriter: init at 2019-11-29 (and update dependency pypandoc to unstable) #75840

Merged
merged 2 commits into from Jan 18, 2020

Conversation

sternenseemann
Copy link
Member

Motivation for this change

Add uberwriter, a simple, but feature-rich markdown editor.

Changes

First I updated pypandoc to an unstable version to make it work with pandoc v2. I based my change on PR #56592. There's also news on the pypandoc situation: It seems like the maintainer of uberwriter will maintain pypandoc in the future.

Then I added a package for uberwriter's current master revision. I chose to use an unstable version because uberwriter recently switched build system. I had already previously tried to get uberwriter to work, but I couldn't manage to make Nix and its custom build system to get along. Now they use meson and ninja which works pretty well together with wrapGAppsHook. As they'll probably stick with this for the next major release 2.2.0, it's probably not worth it to invest any more time into the old build system. Sadly the last beta release also includes this old build system.

I also delete two packages that are distributed with UberWriter: pylocales and pressagio. These could probably be distributed by Nix, but would require light patching of UberWriter. However this is currently not necessary as pylocale is never imported and pressagio is only used in an internal module for auto correct that is in turn never imported, as this feature is not used currently.

Things done

Tested the following features of UberWriter that I am aware of:

  • Editing, Different Editor modes
  • Preview
  • Inline Preview (for footnotes, LaTeX formulas, images ...)
  • Inline Dictonary Integration
  • Dark Mode
  • Export (pdf and xml)
  • Tutorial

What I haven't thoroughly tested so far is Spell Checking with Gspell, as I don't have a proper Gspell dictionary set up on my system. Gspell behaves in Gedit same as in UberWriter, so it seems fine.

  • 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 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.

@sternenseemann sternenseemann changed the title add uberwriter (and update pypandoc to unstable) uberwriter: init at 2019-11-29 (and update dependency pypandoc to unstable) Dec 17, 2019
@ofborg ofborg bot requested a review from bennofs December 17, 2019 22:43
pkgs/applications/editors/uberwriter/default.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/uberwriter/default.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/uberwriter/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pypandoc/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pypandoc/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pypandoc/default.nix Outdated Show resolved Hide resolved
@sternenseemann
Copy link
Member Author

sternenseemann commented Dec 19, 2019

Reworked how dependencies are handled in pypandoc. glibcLocales doesn't seem to be necessary, so I removed it.

cc @bennofs @Twey

@sternenseemann sternenseemann force-pushed the uberwriter-second-attempt branch 3 times, most recently from 63d7897 to f1b0f50 Compare December 19, 2019 12:52
@sternenseemann
Copy link
Member Author

@GrahamcOfBorg build python2Packages.pypandoc python3Packages.pypandoc

1 similar comment
@jonringer
Copy link
Contributor

@GrahamcOfBorg build python2Packages.pypandoc python3Packages.pypandoc

propagatedBuildInputs = [ pip ];
# add pandoc's dependencies to PATH
cat >> pypandoc/__init__.py << EOF
os.environ["PATH"] = "${haskellPackages.pandoc-citeproc}/bin" + os.pathsep + "${texlive.combined.scheme-small}/bin" + os.pathsep + os.environ.get("PATH", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

you want to avoid putting stuff in a user's env, if you want the executables to be available, then you should use patching to edit the source code to call the utility directly

Copy link
Member Author

Choose a reason for hiding this comment

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

I understand that and I am not particularly happy about it, but these are binaries that pandoc calls, which heavily relies on PATH.

For pdflatex we can use the pandoc option --pdf-engine=, I'll look into that. There however doesn't seem to be an equivalent for pandoc-citeproc, maybe --filter could be used, I guess I'll try to achieve it this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

if it's a binary, you can also use the makeWrapper packages, to then wrap the program.

Look for wrapProgram utility in nixpkgs

Copy link
Contributor

Choose a reason for hiding this comment

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

either way, you should not be polluting a user's env

Copy link
Member Author

Choose a reason for hiding this comment

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

I am already using that approach, if you check out the most recent diff. Basically I ignore all (possible) run time dependencies except for pandoc itself in pypandoc and add the required run time dependencies to PATH for uberwriter using wrapGAppsHook.

This is probably the simplest solution to the problem I described in my post below, athough maybe not the best one possible.

@sternenseemann
Copy link
Member Author

sternenseemann commented Dec 22, 2019

I think there is a fundamental problem with packaging pypandoc (maybe even pandoc) for Nix:

First of all pandoc generally uses PATH quite heavily, which is generally fine, as it could theoretically use any program as filter, for example. This becomes problematic, when it comes to optional dependencies of pandoc, like pandoc-citeproc or pdflatex (xetex ...), because it generally assumes to find these programs in PATH, even when they are not explicitly given, like when pandoc is called with --bibliography.

It is possible to work around this issue, e. g. by giving --pdf-engine or --filter explicitly with a path to /nix/store/.... For applications that use pandoc another approach can be used: Setting up a PATH for just the applications containing the dependencies using makeWrapper, so the application doesn't need to be heavily patched.

A real issue comes up concerning pypandoc: It offers full control over pandoc and its options like --filter. This means we can't anticipate all possible usages of pypandoc and set static paths in those cases. Or maybe we could, but It'd mean heavy patching, from what I can tell. Additionally pypandoc has some problematic features for Nix, like the ability to download pandoc dynamically, although this is often not used, like in the case of uberwriter.

My last approach was to setup PATH inside of pypandoc to contain its most common dependencies, texlive and pandoc-citeproc. I agree that this approach isn't ideal. If we don't do that the following tests break, since the required dependencies are not found:

  • test_conversion_with_citeproc_filter
  • test_pdf_conversion

I think there are multiple solutions to this problem, that don't involve going back to the previous approach:

Patching pypandoc

I don't think this makes sense. It would be a lot of effort, as it'd mean to figure out, which dependencies are used from the given pandoc options and filters and replacing them with static paths in the pandoc call. I fear this wouldn't be possible to make 100% reliable and break some applications.

Don't care about dependencies in pypandoc

I guess this is our best bet. Instead of worrying about dependencies (except for pandoc itself which we can set the static path for quite easily) in pypandoc, we require all applications that use it to ensure pandoc will find its dependencies that are acually used, either by setting up the correct PATH using makeWrapper or similar, or by using static paths in the options to pandoc.

To fix the tests we could either disable those two or temporarily set up a PATH containing them just for the testPhase.

I have a mockup of this locally where I removed the addition concerning os.environ["PATH"] and set doCheck = false in pypandoc. It works fine.

Edit: Also it would be possible, although more effort, to patch uberwriter to explicitly use static paths whenever using pypandoc.

Add a pandocWithPackages derivation

Not sure if this is worth it, but essentially we'd add a pandoc derivations that can be called with certain dependencies that would be available to pandoc at runtime. Maybe a long term idea.

I'm not really sure how to proceed here, but I heavily favor option 2 at the moment, as it is the simplest and would make uberwriter work without a lot of effort. I'd love to hear what you think as well!

Switch to an unstable version to make it work with pandoc v2.

Based on NixOS#56592 by @Twey. Reworked dependency handling.
@sternenseemann
Copy link
Member Author

Implemented my idea for the second option on my branch now.

@sternenseemann
Copy link
Member Author

@GrahamcOfBorg build python2Packages.pypandoc python3Packages.pypandoc uberwriter

@bennofs
Copy link
Contributor

bennofs commented Jan 18, 2020

@GrahamcOfBorg build uberwriter

@bennofs bennofs merged commit 5088ef5 into NixOS:master Jan 18, 2020
@bennofs
Copy link
Contributor

bennofs commented Jan 18, 2020

@sternenseemann would you like to become a maintainer of the pypandoc package as well? I'm not actively using it, and if you maintain uberwriter, you have a great way to check if it's actually working.

@sternenseemann
Copy link
Member Author

@bennofs yeah sure, already had a good look into it, so it probably makes sense for me to do it

@sternenseemann sternenseemann deleted the uberwriter-second-attempt branch May 20, 2020 22:09
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