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

onboard: 1.4.1 #24986

Merged
merged 1 commit into from Dec 6, 2017
Merged

onboard: 1.4.1 #24986

merged 1 commit into from Dec 6, 2017

Conversation

johnramsden
Copy link
Member

@johnramsden johnramsden commented Apr 18, 2017

Motivation for this change

onboard is a great on-screen keyboard and in my opinion should be in the repo.

Everything is working and there are no errors at runtime.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@FRidh
Copy link
Member

FRidh commented Apr 18, 2017

We have the function python3.pkgs.buildPythonApplication for building Python packages. See the Nixpkgs manual.

@johnramsden
Copy link
Member Author

@FRidh I'll take another look. I guess I was incorrect when I thought the python specific functions were just for pip packages.


Another thing, when following the manual it says in the quick start section

To test whether the package builds, run the following command from the root of the nixpkgs source tree: $ nix-build -A libfoo

When trying that on NixOS after cloning the repo I get

error: getting status of ‘/home/john/Workspace/Packaging/NixOS/nixpkgs/pkgs/onboard’: No such file or directory

and I have to run it from the package's directory to get it to work. What am I doing wrong?

@FRidh
Copy link
Member

FRidh commented Apr 18, 2017

Write down exactly what you do, since the error message you give does not correspond to the code you show here.

@johnramsden
Copy link
Member Author

After cloning the repo and setting up my package:

Step 5:

run the following command from the root of the nixpkgs source tree:

$ nix-build -A -K onboard

error: getting status of ‘/home/john/Workspace/Packaging/NixOS/nixpkgs/onboard’: No such file or directory

@@ -0,0 +1,45 @@
{ gtk3, python3, hunspell, isocodes, libcanberra_gtk3, xorg.libxkbfile, libxkbcommon, python35Packages.pycairo, python35Packages.dbus-python, python35Packages.pygobject3, python35Packages.systemd, libudev, python35Packages.distutils_extra, gnome3.dconf, pkgconfig, xorg.libXtst
Copy link
Member

@Mic92 Mic92 Apr 18, 2017

Choose a reason for hiding this comment

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

using dot operator here is invalid syntax. Just import python35Packages and xorg.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's strange, I fixed that in the previous commit, I guess I undid the change by accident.

@johnramsden
Copy link
Member Author

I tried to convert to use buildPythonApplication, I keep getting "error: cannot auto-call a function that has an argument without a default value (‘stdenv’)" when I try to build though...

@johnramsden
Copy link
Member Author

So i've tested building and it seems to work until an issue with it being unable to find symlinked files, I think it's possibly related to issue 1232.

error: [Errno 2] No such file or directory: 'Onboard/pypredict/attic/test-client.py'

It occurs in the setup.py, in this code:

def symlink_extension_libraries(setup_command):
    """
    Link the extensions back to the project directory
    so Onboard can be run from source as usual, without --inplace.
    Remove this at any time if there is a better way.
    """
    if setup_command in ["build", "build_ext"]:
        for path, pattern in libs_to_symlink:
            files = glob.glob(join(build_root, path, pattern))
            for file in files:
                dstfile = join(path, split(file)[1])
                print("symlinking {} to {}".format(file, dstfile))

                try: os.unlink(dstfile)
                except OSError: pass
                os.symlink(file, dstfile)

# Make xgettext extract translatable strings from _format() calls too.
var = "XGETTEXT_ARGS"
os.environ[var] = os.environ.get(var, "") + " --keyword=_format"

# scan for translatable layout strings in layouts
# disabled until know how to make it work.
# layoutstring.px has those string manually added now.
if 0:
    if "build_i18n" in sys.argv:
        args = ["./tools/gen_i18n_strings",
                "-o./data/layoutstrings_generated.py"]
        print("Running '{}'".format(" ".join(args)))
        subprocess.check_call(args)

clean_before_build(setup_command)

Any advice?

@johnramsden
Copy link
Member Author

I opened a question on onboards launchpad page in case they could help.

@FRidh FRidh self-assigned this Apr 21, 2017
@johnramsden
Copy link
Member Author

johnramsden commented Apr 21, 2017

So, I was told the 'attic directory wasn't necesary anyway and removed it in the preBuild.

    preBuild = ''
      rm -r Onboard/pypredict/attic
      sed -i 's:/bin/bash:${bash}/bin/bash:' ./setup.py
    '';

marmuta (marmuta) said 1 hour ago: 1
This is probably DistUtilsExtra trying to make sense of the attic files and failing. I'm not sure what exactly happens, you would have to look at auto.py for that.
However the easy fix is to simply delete the offending file(s). Nothing in the attic folder is even used. We should probably remove the whole folder, just to be safe.

marmuta (marmuta) said 45 minutes ago: 2
OK, Onboard/pypredict/attic is gone in trunk. The next release won't have it anymore.

Now i'm getting:

running build_scripts
creating build/scripts-3.5
copying and adjusting onboard -> build/scripts-3.5
copying and adjusting onboard-settings -> build/scripts-3.5
changing mode of build/scripts-3.5/onboard from 644 to 755
changing mode of build/scripts-3.5/onboard-settings from 644 to 755
running build_i18n
intltool-update -p -g onboard
error: [Errno 2] No such file or directory: 'Onboard/pypredict/tools/model_info.py'

@johnramsden
Copy link
Member Author

So the onboard guys gave me some input and I was able to get onboard building, I'm getting some errors though when run. I'm not sure if it's a Nix thing or an onboard thing.

I also changed things to use the Nix specific functions.

I'm now getting the following error when onboard is run:

Traceback (most recent call last):
  File "/nix/store/ar8sjdlrwvaq30gp4mgc3y4xz8nwsy7x-onboard-1.4.1/bin/..onboard-wrapped-wrapped", line 36, in <module>
    from Onboard.OnboardGtk import OnboardGtk as Onboard
  File "/nix/store/ar8sjdlrwvaq30gp4mgc3y4xz8nwsy7x-onboard-1.4.1/lib/python3.5/site-packages/Onboard/OnboardGtk.py", line 35, in <module>
    require_gi_versions()
  File "/nix/store/ar8sjdlrwvaq30gp4mgc3y4xz8nwsy7x-onboard-1.4.1/lib/python3.5/site-packages/Onboard/Version.py", line 24, in require_gi_versions
    gi.require_version('Gtk', '3.0')
  File "/nix/store/sgqhypg37ad4gvgsj5r9gvz1a680xzh3-python3.5-pygobject-3.22.0/lib/python3.5/site-packages/gi/__init__.py", line 118, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available 

@johnramsden
Copy link
Member Author

johnramsden commented Apr 26, 2017

It looks like some typelibs are missing.

marmuta (marmuta) said 16 hours ago:
Great, getting closer.
Is Gtk-3.0.typelib installed? On Ubuntu this is a separate package gir1.2-gtk-3.0 that contains
/usr/lib/x86_64-linux-gnu/girepository-1.0/Gdk-3.0.typelib
/usr/lib/x86_64-linux-gnu/girepository-1.0/GdkX11-3.0.typelib
/usr/lib/x86_64-linux-gnu/girepository-1.0/Gtk-3.0.typelib

Onboard uses all of these and a couple other typelibs:
grep gir debian/control
Depends: gir1.2-gdkpixbuf-2.0,
gir1.2-glib-2.0,
gir1.2-gtk-3.0,
gir1.2-pango-1.0 (>= 1.29.3),
Recommends: gir1.2-appindicator3-0.1,
gir1.2-atspi-2.0,

appindicator3 is for the status icon - optional if the desktop environment is fine with the old GtkStatusIcon. I believe KDE Plasma needs it.
Atspi is for auto-show, word suggestions and others, but not strictly required for a plain keyboard.

I have found the typelibs in <nix store>/lib/girepository-1.0
I can't seem to find a package that provides this but I have seen other people set a variable $GI_TYPELIB_PATH with wrapProgram. Is this the proper way to set the typelibs?

@johnramsden
Copy link
Member Author

johnramsden commented Apr 29, 2017

@FRidh I tried wrapping the package but it didn't help.

 wrapProgram "$out/bin/onboard" \
      --prefix PYTHONPATH : "$PYTHONPATH" \
      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH"

Is there a better way to set the typelibs?

@johnramsden
Copy link
Member Author

johnramsden commented Apr 30, 2017

Should I repost this as an issue?

@johnramsden johnramsden changed the title Add package onboard: 1.4.1 onboard: 1.4.1 May 7, 2017
@johnramsden
Copy link
Member Author

Okay, I finally made some progress. Adding the packages gobjectIntrospection gsettings_desktop_schemas, and wrapGAppsHook it seems to boot but now I'm getting a different error:

** (.onboard-wrapped:6052): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
17:05:26.646 WARNING Onboard.Keyboard: Atspi typelib missing, at-spi key-synth unavailable
17:05:26.656 WARNING Onboard.AtspiStateTracker: Atspi typelib missing, auto-show unavailable
17:05:26.682 WARNING Config: mousetweaks GSettings schema not found, mousetweaks integration disabled.
Traceback (most recent call last):
  File "/nix/store/l8bry5j9nf10kk0vgchx9ghmpblr4qhx-onboard-1.4.1/bin/..onboard-wrapped-wrapped", line 37, in <module>
    ob = Onboard()
  File "/nix/store/l8bry5j9nf10kk0vgchx9ghmpblr4qhx-onboard-1.4.1/lib/python3.5/site-packages/Onboard/OnboardGtk.py", line 148, in __init__
    self.init()
  File "/nix/store/l8bry5j9nf10kk0vgchx9ghmpblr4qhx-onboard-1.4.1/lib/python3.5/site-packages/Onboard/OnboardGtk.py", line 178, in init
    config.init()
  File "/nix/store/l8bry5j9nf10kk0vgchx9ghmpblr4qhx-onboard-1.4.1/lib/python3.5/site-packages/Onboard/Config.py", line 370, in init
    self.install_dir = self._get_install_dir()
  File "/nix/store/l8bry5j9nf10kk0vgchx9ghmpblr4qhx-onboard-1.4.1/lib/python3.5/site-packages/Onboard/Config.py", line 1449, in _get_install_dir
    assert(result) # warn early when the installation dir wasn't found
AssertionError

@johnramsden
Copy link
Member Author

Whoo! Got it running. Just need to fix a few errors and it should be ready!

@johnramsden
Copy link
Member Author

The issue with seems to be related to how the file sokSettings.py is being wrapped. I'm using wrapGAppsHook and the program wants to import a module but it is importing the bash script wrapper which actually calls the module, instead of importing the Python module. Does anyone know if there is a way to exclude certain files with the wrappers?


When the Python script attempts to import sokSettings.py the following happens:

python3 -c "import scripts.sokSettings; scripts.sokSettings.run()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/nix/store/5cwnb0da5rjm9ni4pf1fg7i2ng6k5c8j-onboard-1.4.1/share/onboard/scripts/sokSettings.py", line 2
    export PATH=/nix/store/76rgpkm1jqgqwz4bjnk8y37z29q82zgy-python3-3.5.3/bin:/nix/store/5cwnb0da5rjm9ni4pf1fg7i2ng6k5c8j-onboard-1.4.1/bin:/nix/store/63spjx86svppz695s5yy7mh2h6lbbca1-gtk+3-3.22.8-dev/bin:/nix/store/k6bmqyh6yf8pzrhnfbzkqdrb3g0hb5gj-expat-2.2.0-dev/bin:/nix/store/pmp2ysvnrmcfzdjmaqnyhda96zkf2z6f-glib-2.50.3-dev/bin:/nix/store/8xm32qg4xi1l41zng4xv752492h6wmdp-cairo-1.14.8-dev/bin:/nix/store/dg3c94l36n3zmrpq9p9qyfi6407rhv5f-freetype-2.6.5-dev/bin:/nix/store/6fc4ak60p1mnilrjfcyz0sywwmpmf45w-bzip2-1.0.6.0.1-bin/bin:/nix/store/j8japwvk2qq8wf9yddibs4fnp99hskkw-libpng-apng-1.6.28-dev/bin:/nix/store/fsqw38ydj8wfj606rzkdcb3rrmpnhb4q-fontconfig-2.12.1-bin/bin:/nix/store/3hz3ll4ikznx3b6cd3myvrm5i79kyj8y-harfbuzz-1.4.2-dev/bin:/nix/store/pr6x655sz1n1sqjhch2i64h5l8i48xrm-graphite2-1.3.6/bin:/nix/store/7wc7qlqg7vsbav3vrjmkfbjbxpp9nnpr-pango-1.40.3-bin/bin:/nix/store/mrzs48prbr7aync14ns4l2j2s489sx50-gdk-pixbuf-2.36.5-dev/bin:/nix/store/sqxw6zlqy91y5nhl4smr5smixkqhdr1k-libjpeg-turbo-1.5.1-bin/bin:/nix/store/s2hmf51bprsxb20v3bfigs8a7zsw3hjl-xz-5.2.2-bin/bin:/nix/store/i14lfjn7cgfmghak3hqczmd90dymsbaj-libtiff-4.0.7-bin/bin:/nix/store/8iavg1dpbz7w9lqgv35q0a6hdkr0gpxi-jasper-2.0.12-bin/bin:/nix/store/pj75dhcgcnnv7ws860bs2zf23hzk2bjz-gdk-pixbuf-2.36.5/bin:/nix/store/qja3mjgiz9c7ld1ddffgc7b487mv1zmh-gobject-introspection-1.50.0-dev/bin:/nix/store/6l6kkkvbz9nxc7pi8m4wcq0z60bmp74a-wayland-1.12.0/bin:/nix/store/q5l53jgm2crfih93l56lcl8mxjywygs9-cups-2.1.4-dev/bin:/nix/store/3gi4zw66q73hdal18akrca30rf02zblq-cups-2.1.4/bin:/nix/store/bx1091kbmwff89gmmxy3za426ryxg0jm-gtk+3-3.22.8/bin:/nix/store/2byhribnzhiy7zhp838fc833xdhnl5l8-dconf-0.26.0/bin:/nix/store/iwm7yk3a40wn400wlqv0rx0zhc7rk756-libcanberra-0.30/bin:/nix/store/px7a1kq4prjzw17c9pppssdmibqqdm2p-systemd-232/bin:/nix/store/fi3mbd2ml4pbgzyasrlnp0wyy6qi48fh-bash-4.4-p5/bin:/nix/store/nqini3ad62zhsknqdpsjcgcm68d1n4gl-hunspell-1.3.3-bin/bin:/nix/store/q2djjbafrmarpv3iqc6scqnsxrdlqxvb-pkg-config-0.29/bin:/nix/store/0l73r9z7q5zjyvghnkd9wm8bihf9gg2p-intltool-0.51.0/bin:/nix/store/lkdr3z34n6n17g7xiaw8plyw7hv9idsl-gettext-0.19.8/bin:/nix/store/nsa311yg8h93wfaacjk16c96a98bs09f-perl-5.22.3/bin:/nix/store/4yn2vyzz1mwl9ry9l67y9bmyasjp7jrj-python3.5-setuptools-30.2.0/bin:/nix/store/087w6yxwq3skp2zppahq8dvfa2idckv7-librsvg-2.40.16/bin${PATH:+:}$PATH
              ^
SyntaxError: invalid syntax

This is what it should be importing:

cat share/onboard/scripts/.sokSettings.py-wrapped
#!/nix/store/76rgpkm1jqgqwz4bjnk8y37z29q82zgy-python3-3.5.3/bin/python3

import sys;import site;import functools;sys.argv[0] = '/nix/store/5cwnb0da5rjm9ni4pf1fg7i2ng6k5c8j-onboard-1.4.1/share/onboard/scripts/sokSettings.py';functools.reduce(lambda k, p: site.addsitedir(p, k), ['/nix/store/5cwnb0da5rjm9ni4pf1fg7i2ng6k5c8j-onboard-1.4.1/lib/python3.5/site-packages','/nix/store/fs8cxcjdm2zf8arxmbva7k742n7mkklm-python3.5-pycairo-1.10.0/lib/python3.5/site-packages','/nix/store/4yn2vyzz1mwl9ry9l67y9bmyasjp7jrj-python3.5-setuptools-30.2.0/lib/python3.5/site-packages','/nix/store/7kfnj63b4pav99zgq24cjxx3cjgl3xq2-python3.5-dbus-python-1.2.4/lib/python3.5/site-packages','/nix/store/168n92ld073flhld87hz4nv39vr44rd7-python3.5-pygobject-3.22.0/lib/python3.5/site-packages','/nix/store/3j9whdk7zqif6jj9alrm8i3d0fx8ma7c-python3.5-python-systemd-231/lib/python3.5/site-packages','/nix/store/42dan8qv7ffjbwzqcnzdqw3mr16imwzp-python3.5-distutils-extra-2.39/lib/python3.5/site-packages','/nix/store/6f4piaq9la15ljqjjz0fyzf653kcfj5l-pyatspi-2.18.0/lib/python3.5/site-packages'], site._init_pathinfo());
PYTHON_EXECUTABLE = "python3"

from gi.repository import GLib

def run():
    GLib.spawn_async(argv=[PYTHON_EXECUTABLE,
                           "-cfrom Onboard.settings import Settings\ns = Settings(False)"],
                     flags=GLib.SpawnFlags.SEARCH_PATH)

@johnramsden johnramsden changed the base branch from master to 0.5-stable May 30, 2017 20:15
@johnramsden johnramsden changed the base branch from 0.5-stable to master May 30, 2017 20:20
@johnramsden
Copy link
Member Author

johnramsden commented Jun 16, 2017

Now the setting application actually runs.

I hardcoded it to execute the specific executable of the settings module, how it was set before stopped settings from starting.

      substituteInPlace ./scripts/sokSettings.py \
        --replace "#!/usr/bin/python3" "" \
        --replace "PYTHON_EXECUTABLE," "\"$out/bin/onboard-settings\"" \
        --replace '"-cfrom Onboard.settings import Settings\ns = Settings(False)"' ""

This ends up giving us the following:

def run():
    GLib.spawn_async(argv=["/nix/store/7qwvy80hj1spg513944lrspwjl2nsrn9-onboard-1.4.1/bin/onboard-settings"
                           ],
                     flags=GLib.SpawnFlags.SEARCH_PATH)

The issue is the settings application doesn't do anything. It won't change any settings. I'm wondering if it could be related to the fact that the store is considered read only?

--replace "/usr/lib" "$out/lib"

substituteInPlace ./data/org.onboard.Onboard.service \
--replace "/usr/bin" "out/bin"
Copy link
Member

Choose a reason for hiding this comment

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

you are missing '$' in $out here and below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks.

@johnramsden
Copy link
Member Author

So, marmuta from onboard thinks it might have something to do with 'gsettings'.

marmuta (marmuta) said 14 hours ago: #36
Do things like
gsettings get org.onboard layout
work?
Or try running dconf-editor for the same with a GUI tool.

I tried adding a few packages that I thought might might provide gsettings as build inputs, but it doesn't seem to do anything or add the package.

buildInputs = [ gnome3.gconf gnome3.dconf gnome3.dconf-editor ];

I'm not sure what should be providing gsettings.

@johnramsden
Copy link
Member Author

For some reason glib schemas are not being installed. I posted an issue regarding the problem.

@johnramsden
Copy link
Member Author

It looks like the problem I was getting with the settings was not related to the glib schema compilation. I found out that the fix was to install gnome3.dconf system-wide. For some reason just adding it to buildInputs doesn't work.

I reverted the schema back to how it was before, which seems to be working.

The on-screen keyboard is now in a usable state. I'm now working on getting rid of the remaining warnings that show up at the start of the program:

** (.onboard-wrapped:16998): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
14:40:03.814 WARNING Onboard.Keyboard: Atspi typelib missing, at-spi key-synth unavailable
14:40:03.824 WARNING Onboard.AtspiStateTracker: Atspi typelib missing, auto-show unavailable
14:40:03.851 WARNING Config: mousetweaks GSettings schema not found, mousetweaks integration disabled.

(onboard:16998): Gtk-WARNING **: Theme parsing error: gtk.css:68:35: The style property GtkButton:child-displacement-x is deprecated and shouldn't be used anymore. It will be removed in a future version

(onboard:16998): Gtk-WARNING **: Theme parsing error: gtk.css:69:35: The style property GtkButton:child-displacement-y is deprecated and shouldn't be used anymore. It will be removed in a future version

(onboard:16998): Gtk-WARNING **: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version

@johnramsden
Copy link
Member Author

Got rid of last few warnings. Added at_spi2_core as optional, enabling atspiSupport gets rid of warning:

17:16:03.997 WARNING Onboard.Keyboard: Atspi typelib missing, at-spi key-synth unavailable
17:16:04.009 WARNING Onboard.AtspiStateTracker: Atspi typelib missing, auto-show unavailable

Enable service 'services.gnome3.at-spi2-core.enable = true' to get rid of warning:

WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files

@jtojnar
Copy link
Contributor

jtojnar commented Dec 4, 2017

Yes, this should be enough. hunspell is a multiple output derivation and the files needed for pkgconfig to find it are in the dev output. When using hunspell as a direct dependency, the dev output is available to onboard, but when it is hidden inside hunspellWithDicts, the dev output is not propagated making the pkgconfig unable to find it.

@jtojnar
Copy link
Contributor

jtojnar commented Dec 4, 2017

I will test it later but it looks good to merge.

In the future, we might want to look into the remaining test failures, probably in cooperation with upstream. We will also want to allow users to chose which hunspell dictionaries to install.

@johnramsden
Copy link
Member Author

johnramsden commented Dec 4, 2017

@jtojnar That sounds like a good idea, adding the ability to choose which dictionaries to use could be customized with install options in the future.

I've never tried using the dictionary so I'm not sure how they work, but I tried enabling word suggestions and the keyboard would no longer open, so something must be wrong.
EDIT: Just needed to enable the atspi service

I have found Upstream to be very responsive to issues in the past so I'm sure if we asked them they would give us a hand.

At least now the core functionality of the keyboard is working though, which is great for accessibility on NixOS. The current alternative xvkbd works, but Onboard is a much better keyboard.

If you think it is ready to merge, to make things easier should I squash my commits?


@jtojnar Thanks for all your help getting things working properly, your help is much appreciated.

@FRidh
Copy link
Member

FRidh commented Dec 4, 2017

We will also want to allow users to chose which hunspell dictionaries to install.

Typically these kind of things are kept impure for during runtime, that is, you need to explicitly install yourself hunspell with certain dictionaries. The reason is that one otherwise would have to copy interfaces and because its unlikely that you would need multiple versions of hunspell during runtime.

I leave it open whether you should do it like this or not.

@jtojnar
Copy link
Contributor

jtojnar commented Dec 4, 2017

Typically these kind of things are kept impure for during runtime, that is, you need to explicitly install yourself hunspell with certain dictionaries.

In that case we would want to replace /usr/share/hunspell with just hunspell, add customHunspell to checkInputs and mention the need to install them in a comment at the top of the file or in the longDescription (not sure which is more idiomatic).

@johnramsden
Copy link
Member Author

johnramsden commented Dec 4, 2017

@jtojnar Is this better?

Also, what is the purpose for replacing /usr/share/hunspell with just hunspell?

@jtojnar
Copy link
Contributor

jtojnar commented Dec 5, 2017

My bad, I misread /usr/share/hunspell as /usr/bin/hunspell and wanted to change it to just the program name so it would be looked up on PATH. Since that is actually a path to the dictionaries, we want to use paths where the dictionaries will be installed to, like /var/run/current-system/sw/share/hunspell/ and /home/username/.nix-profile/share/hunspell. Or we could ignore the hunspell class, relying on the hunspell_cmd which works seamlessly with hunspellWithDicts installed on the system path; though, I did not find out how is the spell-checker supposed to work in onboard or how to switch the backend.

@johnramsden
Copy link
Member Author

@jtojnar in other words, change /usr/share/hunspell to $out/share/hunspell then, right?

I couldn't figure out how the spell-checker was supposed to work either.

@jtojnar
Copy link
Contributor

jtojnar commented Dec 5, 2017

No, that would not work. $out points to the onboard directory in the nix store. We would need to use a patch like this, in order to be able to use hunspell backend:

=== modified file 'Onboard/SpellChecker.py'
--- Onboard/SpellChecker.py	2015-02-10 00:09:01 +0000
+++ Onboard/SpellChecker.py	2017-12-05 14:49:31 +0000
@@ -506,6 +506,10 @@
         if dicpath:
             paths.extend(dicpath.split(pathsep))
 
+        datadirs = os.getenv("XDG_DATA_DIRS")
+        if datadirs:
+            paths.extend(map(lambda datadir: os.path.join(datadir, 'hunspell'), datadirs.split(pathsep)))
+
         paths.extend(LIBDIRS)
 
         home = os.getenv("HOME")

@johnramsden
Copy link
Member Author

Okay, I'll apply the patch and set the path to what then?

@jtojnar
Copy link
Contributor

jtojnar commented Dec 5, 2017

No need for substitution then. I would also move some things around and add more comments:

--- a/pkgs/applications/misc/onboard/default.nix
+++ b/pkgs/applications/misc/onboard/default.nix
@@ -28,11 +28,10 @@
 
 let
   customHunspell = hunspellWithDicts [hunspellDicts.en-us];
-in
-python3.pkgs.buildPythonApplication rec {
-  name = "onboard-${version}";
   majorVersion = "1.4";
   version = "${majorVersion}.1";
+in python3.pkgs.buildPythonApplication rec {
+  name = "onboard-${version}";
   src = fetchurl {
     url = "https://launchpad.net/onboard/${majorVersion}/${version}/+download/${name}.tar.gz";
     sha256 = "01cae1ac5b1ef1ab985bd2d2d79ded6fc99ee04b1535cc1bb191e43a231a3865";
@@ -43,8 +42,14 @@
   doCheck = false;
   checkInputs = [
     python3.pkgs.nose
+    # for Onboard.SpellChecker.hunspell_cmd doctests
     customHunspell
+    # for Onboard.SpellChecker.aspell_cmd doctests
     (aspellWithDicts (dicts: with dicts; [ en ]))
+    # for Onboard.SpellChecker.hunspell doctests
+    hunspellDicts.en-us
+    hunspellDicts.es-es
+    hunspellDicts.it-it
   ];
 
   propagatedBuildInputs = [
@@ -83,6 +88,11 @@
     gnome3.dconf
   ];
 
+  patches = [
+    # Allow loading hunspell dictionaries installed in NixOS system path
+    ./use-xdg-datadirs.patch
+  ];
+
   preBuild = ''
     # Unnecessary file, has been removed upstream
     # https://github.com/NixOS/nixpkgs/pull/24986#issuecomment-296114062
@@ -108,7 +118,6 @@
       --replace "/usr/bin/yelp" "${yelp}/bin/yelp"
 
     substituteInPlace  ./Onboard/SpellChecker.py \
-      --replace "/usr/share/hunspell" hunspell \
       --replace "/usr/lib" "$out/lib"
 
     substituteInPlace  ./data/org.onboard.Onboard.service  \

meta = {
homepage = https://launchpad.net/onboard;
description = "An onscreen keyboard useful for tablet PC users and for mobility impaired users.";
longDescription = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

I would get rid of the long description. dconf is now added automatically thanks to propagatedUserEnvPkgs, changing advanced configuration is not NixOS specific, the a11y bus is not specific to this package… The only thing that matters is hunspell and we are do not even know how to use it.

@johnramsden
Copy link
Member Author

I went ahead and added the patch, as well as some comments, and did a bit of reorganizing.

in python3.pkgs.buildPythonApplication rec {
name = "onboard-${version}";
majorVersion = "1.4";
version = "${majorVersion}.1";
Copy link
Contributor

Choose a reason for hiding this comment

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

It is preferred to move the helper definitions (like version) to the let statement in order not to pollute the build environment.

postInstall = ''
cp onboard-default-settings.gschema.override.example $out/share/glib-2.0/schemas/10_onboard-default-settings.gschema.override

${glib.dev}/bin/glib-compile-schemas $out/share/glib-2.0/schemas/
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for absolute path to glib-compile-schemas since it is already on path, thanks to being in build inputs.

@@ -0,0 +1,157 @@
{ config
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this for?

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 I think that remains from when I was using it as one of my own custom packages. I'll remove it.

Copy link
Contributor

@jtojnar jtojnar left a comment

Choose a reason for hiding this comment

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

Thanks for your great work, you can squash it now and I will merge it.

@jtojnar
Copy link
Contributor

jtojnar commented Dec 6, 2017

The commit message seems to mention uncommenting checkInputs.

Add testing reqs, but keep tests disabled

Tests are runnable but still produce errors.

To get tests working, add locale setting, replace killall
and add nose package. To run the tests enable 'doCheck'.

Hunspell needs to be explicitly installed to use.

Patch SpellCheck.py to put hunspell in system datadir location.
For example, '/var/run/current-system/sw/share/hunspell/'
or '${HOME}/.nix-profile/share/hunspell/'

To get rid of atspi errors set
'services.gnome3.at-spi2-core.enable = true'
@johnramsden
Copy link
Member Author

@jtojnar Where are you referring to?

@jtojnar
Copy link
Contributor

jtojnar commented Dec 6, 2017

image

@johnramsden
Copy link
Member Author

@jtojnar Whoops, fixed.

@jtojnar jtojnar merged commit fcd04a9 into NixOS:master Dec 6, 2017
@jtojnar
Copy link
Contributor

jtojnar commented Dec 6, 2017

Thanks.

@johnramsden
Copy link
Member Author

@jtojnar Thanks for being so patient with me. I appreciate your help in getting this to work.

@jtojnar
Copy link
Contributor

jtojnar commented Dec 6, 2017

Hmm, it should be possible to make the dconf tests work with dbus-run-session see

xvfb-run -s '-screen 0 800x600x24' dbus-run-session \
--config-file=${dbus.daemon}/share/dbus-1/session.conf \

@johnramsden
Copy link
Member Author

@jtojnar Interesting. How exactly would I go about replacing the check command that's run with dbus-run-session -- make check. In the example given dbus is used to run a shell before the check command. Should I just disable checks and run it manually with dbus-run-session -- make check?

@jtojnar
Copy link
Contributor

jtojnar commented Dec 7, 2017

@johnramsden Simply replacing the checkPhase should be sufficient

--- a/pkgs/applications/misc/onboard/default.nix
+++ b/pkgs/applications/misc/onboard/default.nix
@@ -3,6 +3,7 @@
 , aspellWithDicts
 , at_spi2_core ? null
 , atspiSupport ? true
+, dbus
 , bash
 , glib
 , glibcLocales
@@ -57,6 +59,7 @@ in python3.pkgs.buildPythonApplication rec {
     hunspellDicts.es-es
     hunspellDicts.it-it
 
+    dbus.daemon
     python3.pkgs.nose
   ];
 
@@ -147,6 +151,12 @@ in python3.pkgs.buildPythonApplication rec {
     glib-compile-schemas $out/share/glib-2.0/schemas/
   '';
 
+  checkPhase = ''
+    dbus-run-session \
+      --config-file=${dbus.daemon}/share/dbus-1/session.conf \
+      python setup.py test
+  '';
+
   meta = {
     homepage = https://launchpad.net/onboard;
     description = "An onscreen keyboard useful for tablet PC users and for mobility impaired users.";

Though now it seems to hang for me.

@johnramsden
Copy link
Member Author

johnramsden commented Dec 7, 2017

@jtojnar Yea, the test seems to run but I get a lot of failures still, and it seems to hang that you mentioned. I'm not even sure where to start. I wonder if we should wait for some help from the onboard guys regarding the tests.

@jtojnar
Copy link
Contributor

jtojnar commented Dec 7, 2017

I suspect the AttributeError (module 'pypredict' has no attribute 'lm') ... ERROR is caused by tests not being wrapped. I tried various combinations of env vars, including the following but nothing really seems to help.

  checkPhase = ''
    export PYTHONPATH="$out/lib/${python3.libPrefix}/site-packages:$PYTHONPATH"
    export PYDIR=$out/lib/${python3.libPrefix}/site-packages
    export XDG_DATA_DIRS="$out/share:$XDG_DATA_DIRS"
    export GIO_EXTRA_MODULES="$out/lib/gio/modules:$GIO_EXTRA_MODULES"
    dbus-run-session \
      --config-file=${dbus.daemon}/share/dbus-1/session.conf \
      sh -c " \
        ${gnome3.dconf.lib}/libexec/dconf-service & \
        python setup.py test
      "
  '';

Maybe some Nix Python people might help too.

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

9 participants