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

ulauncher: 4.4.0.r1 -> 5.6.1 #81207

Merged
merged 1 commit into from Mar 27, 2020

Conversation

aaronjanse
Copy link
Member

Motivation for this change

Package update request #81178

The actual version is outdated and almost no extension work on it. I'm not skilled enough to mage the derivation (even if I'm currently trying :p).

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.

For some reason, I got the following non-fatal error upon first run (or rm -rf ~/.cache/ulauncher_cache ~/.config/ulauncher), which didn't seem to break anything:

2020-02-27 13:07:53,504 | ERROR | ulauncher: except_hook() | Uncaught exception
Traceback (most recent call last):
  File "/nix/store/xky23w5sd8mbm9rpgjl1b8iqz70kjc77-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/ui/windows/UlauncherWindow.py", line 298, in bind_show_app_hotkey
    self.notify_hotkey_change(accel_name)
  File "/nix/store/xky23w5sd8mbm9rpgjl1b8iqz70kjc77-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/ui/windows/UlauncherWindow.py", line 307, in notify_hotkey_change
    show_notification("Ulauncher", "Hotkey is set to %s" % display_name)
  File "/nix/store/xky23w5sd8mbm9rpgjl1b8iqz70kjc77-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/utils/desktop/notification.py", line 13, in show_notification
    Notify.Notification.new(summary, body, icon).show()
gi.repository.GLib.GError: g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files (2)

Also, when changing the theme, I get a permission error for a cache file. This is fixed by running with sudo, but, of course, running as root doesn't sound like a good idea.

2020-02-27 13:11:26,641 | ERROR | ulauncher: except_hook() | Uncaught exception
Traceback (most recent call last):
  File "/nix/store/xky23w5sd8mbm9rpgjl1b8iqz70kjc77-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/ui/windows/PreferencesUlauncherDialog.py", line 307, in prefs_set_theme_name
    ulauncher_window.init_theme()
  File "/nix/store/xky23w5sd8mbm9rpgjl1b8iqz70kjc77-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/ui/windows/UlauncherWindow.py", line 227, in init_theme
    self.init_styles(theme.compile_css())
  File "/nix/store/xky23w5sd8mbm9rpgjl1b8iqz70kjc77-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/utils/Theme.py", line 120, in compile_css
    with open(generated_css, 'w') as new_css_file:
PermissionError: [Errno 13] Permission denied: '/home/ajanse/.cache/ulauncher_cache/themes/ubuntu/generated.css'

Other than the issues listed above, Ulauncher seems to work fine.

I don't know what to do about the test in the derivation and the disabled attribute.

@worldofpeace
Copy link
Contributor

It's weird these weren't in buildInputs already, but here:

  • glib
  • gtk3
  • gdk-pixbuf

just reading the docs and inspecting from gi.repository imports.

@worldofpeace
Copy link
Contributor

It seems we have a file in the incorrect directory again

├── lib
│   └── python3.6
│       └── site-packages
│           ├── nix
│           │   └── store
│           │       └── fxpc54y7r5jdjgrgb98inybkn22fm0vz-python3-3.6.10
│           │           └── share
│           │               └── applications
│           │                   └── extras-ulauncher.desktop

@aaronjanse
Copy link
Member Author

aaronjanse commented Feb 28, 2020 via email

@NicolasGuilloux
Copy link

So I tried to start it on my computer, and I get this error while running with my regular user:

2020-03-01 19:52:06,620 | ERROR | ulauncher: except_hook() | Uncaught exception
Traceback (most recent call last):
  File "/nix/store/m2dqq3jr4dqr99ywg8j06yzdx3nz1r4j-ulauncher-5.6.1/bin/..ulauncher-wrapped-wrapped", line 29, in <module>
    main()
  File "/nix/store/m2dqq3jr4dqr99ywg8j06yzdx3nz1r4j-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/main.py", line 128, in main
    window = UlauncherWindow.get_instance()
  File "/nix/store/m2dqq3jr4dqr99ywg8j06yzdx3nz1r4j-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/utils/decorator/singleton.py", line 19, in wrapper
    instance = fn(*args, **kwargs)
  File "/nix/store/m2dqq3jr4dqr99ywg8j06yzdx3nz1r4j-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/ui/windows/UlauncherWindow.py", line 55, in get_instance
    return cls()
  File "/nix/store/m2dqq3jr4dqr99ywg8j06yzdx3nz1r4j-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/ui/windows/UlauncherWindow.py", line 65, in __new__
    new_object.finish_initializing(builder)
  File "/nix/store/m2dqq3jr4dqr99ywg8j06yzdx3nz1r4j-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/ui/windows/UlauncherWindow.py", line 98, in finish_initializing
    self.init_theme()
  File "/nix/store/m2dqq3jr4dqr99ywg8j06yzdx3nz1r4j-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/ui/windows/UlauncherWindow.py", line 227, in init_theme
    self.init_styles(theme.compile_css())
  File "/nix/store/m2dqq3jr4dqr99ywg8j06yzdx3nz1r4j-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/utils/Theme.py", line 119, in compile_css
    generated_css = self._get_path_for_generated_css()
  File "/nix/store/m2dqq3jr4dqr99ywg8j06yzdx3nz1r4j-ulauncher-5.6.1/lib/python3.6/site-packages/ulauncher/utils/Theme.py", line 138, in _get_path_for_generated_css
    rmtree(new_theme_dir)
  File "/nix/store/fxpc54y7r5jdjgrgb98inybkn22fm0vz-python3-3.6.10/lib/python3.6/shutil.py", line 486, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/nix/store/fxpc54y7r5jdjgrgb98inybkn22fm0vz-python3-3.6.10/lib/python3.6/shutil.py", line 444, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/nix/store/fxpc54y7r5jdjgrgb98inybkn22fm0vz-python3-3.6.10/lib/python3.6/shutil.py", line 442, in _rmtree_safe_fd
    os.unlink(name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'theme.css'

When I run it as root (which is bad °o°), it works perfectly expect all extensions crash. I don't know why, but probably because it is launched from the root space instead of the user space.

Let me know if you want more testing :)

@aaronjanse
Copy link
Member Author

The notification error was fixed by me starting a notifications daemon, so I think that problem was on my end (i.e. it isn't a problem with the derivation).

I also figured out the permissions error. Patch coming soon!

@aaronjanse
Copy link
Member Author

Turns out the permission error was caused by ulauncher copying its default themes from the nix store (which is read-only). Other than that, I just added the dependencies @worldofpeace suggested then switched python36 to python3 :-)

@ofborg ofborg bot requested a review from worldofpeace March 2, 2020 21:22
@worldofpeace
Copy link
Contributor

@aaronjanse You can actually PR that fix-permissions.patch upstream. This is a frequent bug in software where they don't chmod the file to the correct permissions, and it won't just affect NixOS (so it isn't nixos specific code)

@worldofpeace
Copy link
Contributor

On that note, I've discovered a nixos specific bug 😁

I noticed this error while running the app:

2020-03-03 20:56:12,039 | WARNING | ulauncher.utils.image_loader: load_image() | Could not load image /nix/store/91givlax93csd9l1k0i2ffszmdxdy25l-ulauncher-4.3.2.r8/share/ulauncher/media/stackoverflow-icon.svg. E: g-file-error-quark: Failed to open file “/nix/store/91givlax93csd9l1k0i2ffszmdxdy25l-ulauncher-4.3.2.r8/share/ulauncher/media/stackoverflow-icon.svg”: No such file or directory (4)

this lead me to believe some sort of config file has hardcoded paths to the old output.

From looking at .config/ulanucher/shortcuts.json this was true:

@worldofpeace worldofpeace changed the title ulauncher: 4.4.0.r1 -> 5.6.1 [WIP] ulauncher: 4.4.0.r1 -> 5.6.1 Mar 4, 2020
@aaronjanse
Copy link
Member Author

this lead me to believe some sort of config file has hardcoded paths to the old output.
As in, the config files point to the original output that generated ~/.config/ulauncher, which may have been garbage collected since then?

If so, that's a tricky. Do you recommend patching ulauncher in this PR to address the bug?

@worldofpeace
Copy link
Contributor

this lead me to believe some sort of config file has hardcoded paths to the old output.
As in, the config files point to the original output that generated ~/.config/ulauncher, which may have been garbage collected since then?

If so, that's a tricky. Do you recommend patching ulauncher in this PR to address the bug?

I'm not sure why they need an icon key at all. The best patch would be to find this icon recursing from XDG_DATA_DIRS using GLib.get_system_data_dirs, though that's a little complex given I don't know what the icons are/for. We can rely on this because it will be linked at /run/current-system/sw/share.

The easiest thing would be to somehow make it always be /run/current-system/sw/share/ulauncher/media, similar to how one could expect that to be /usr/share/ulauncher/media. But we'd keep that patch forever.

@aaronjanse
Copy link
Member Author

though that's a little complex given I don't know what the icons are/for

My understanding is that the icons are for Ulauncher search results.

For example, a search for "duck" might show:

[Search bar contents: duck]
[Google icon] Google search for "duck"
[Wikipedia icon] Wikipedia search for "duck"

My understanding is that Ulauncher provides default icons that can be overwritten by the user. I assume that if Ulauncher updates its default icons, users relying on the default icons should have their icons updated. So yes, /run/current-system/sw/share/ulauncher/media does seem like it would make a lot of sense.

@aaronjanse
Copy link
Member Author

Is there any existing Nix derivation (or documentation) you recommend I look at for learning how to use /run/current-system/sw/share? I've tried grepping Nixpkgs to no avail.

@worldofpeace
Copy link
Contributor

Is there any existing Nix derivation (or documentation) you recommend I look at for learning how to use /run/current-system/sw/share? I've tried grepping Nixpkgs to no avail.

I've found the code https://github.com/Ulauncher/Ulauncher/blob/42b83349406c42ee8d23dc7eae1d2a9d42ba6937/ulauncher/config.py#L45.

The code to do this would be https://github.com/Ulauncher/Ulauncher/blob/42b83349406c42ee8d23dc7eae1d2a9d42ba6937/ulauncher/config.py#L26 but with ulauncher/media/.

@aaronjanse
Copy link
Member Author

Hmm, my understanding is that putting files in /run/current-system/sw requires creating a module for Ulauncher. Is that correct?

If so, should the ulauncher icons patch fallback to using hard-coded /nix/store paths if the package is installed without the module being enabled?

@aaronjanse
Copy link
Member Author

As a side note, I do think it would be nice to have a module for Ulauncher. I assume most people using Ulauncher would want it running in a systemd service.

@worldofpeace
Copy link
Contributor

worldofpeace commented Mar 4, 2020

Hmm, my understanding is that putting files in /run/current-system/sw requires creating a module for Ulauncher. Is that correct?

If so, should the ulauncher icons patch fallback to using hard-coded /nix/store paths if the package is installed without the module being enabled?

No it doesn't. That is because it's one of the directories that automatically gets linked from environment.systemPackages. Additionally, because we use wrapGAppsHook, this wraps XDG_DATA_DIRS to always have the nix store path ${ulauncher.out}/share. So this is perfect to rely on.

@aaronjanse
Copy link
Member Author

aaronjanse commented Mar 4, 2020

We can rely on this because it will be linked at /run/current-system/sw/share

Hmm. On my system, tree /run/current-system/sw | grep -i ulauncher returns no results after running nix-build on a local nixpkgs.

EDIT: ohhh, I think you meant to say it's only linked when the package is put in environment.systemPackages?

This wraps XDG_DATA_DIRS to always have the nix store path ${ulauncher.out}/share. So this is perfect to rely on.

Hmm, I guess I don't understand. Should I patch ulauncher so that it, instead of turning XDG_DATA_DIRS into an abs path on the first run, stores literally $XDG_DATA_DIRS/ulauncher/media/google-search-icon.png in shortcuts.json then make the path string absolute (in memory, not in the file) each time ulauncher is run?

@worldofpeace
Copy link
Contributor

We can rely on this because it will be linked at /run/current-system/sw/share

Hmm. On my system, tree /run/current-system/sw | grep -i ulauncher returns no results after running nix-build on a local nixpkgs.

sw structure is like all the subdirs of a nix output linked, so it would be sw/share/ulauncher/media`

This wraps XDG_DATA_DIRS to always have the nix store path ${ulauncher.out}/share. So this is perfect to rely on.

Hmm, I guess I don't understand. Should I patch ulauncher so that it, instead of turning XDG_DATA_DIRS into an abs path on the first run, stores literally $XDG_DATA_DIRS/ulauncher/media/google-search-icon.png in shortcuts.json then make the path string absolute (in memory, not in the file) each time ulauncher is run?

Ohh, I see what you mean. If the wrapper adds this entry

export XDG_DATA_DIRS='/nix/store/afnicf324bk54w1bw5zi4zydlixgpnr8-ulauncher-5.6.1/share'${XDG_DATA_DIRS:+':'}$XDG_DATA_DIRS

that would defeat the purpose if we choose that entry.

But XDG_DATA_DIRS is a list (in pyxdg)

>>> from xdg.BaseDirectory import xdg_config_home, xdg_cache_home, xdg_data_dirs, xdg_data_home
>>> xdg_data_dirs
['/home/worldofpeace/.local/share', '/nix/store/lf040bkq02bq7jar5i3vdnx2dg7x8mpq-tilix-unstable-2019-10-02/share', '/nix/store/kmyl5fj7ak1vxyb5spaxwgh3xkh1zi6p-gtk+3-3.24.13/share/gsettings-schemas/gtk+3-3.24.13'..]

and one of those entries on NixOS will always be /run/current-system/sw/share.
(not entirely sure why they use pyxdg here, glib has the same functions).

So similar to how this code is

DESKTOP_DIRS = list(filter(os.path.exists, [os.path.join(dir, "applications") for dir in xdg_data_dirs]))

we should add something to filter out /nix/store because those paths aren't good.

@NicolasGuilloux
Copy link

Hum I tested the application, and it seems really good :)

I get a new error though. It seems that the python websocket library is mandatory for each extension. Indeed, I get the same error during the extension import process.

file:///nix/store/461vbpcm4vaymwn649nsgj6d0x34xg09-ulauncher-5.6.1/share/ulauncher/preferences/dist/static/js/app.3ac7a6c3198ad21851fb.js:4919:18: CONSOLE ERROR TypeError: e.cancel is not a function. (In 'e.cancel()', 'e.cancel' is undefined)
Traceback (most recent call last):
  File "/home/nover/.local/share/ulauncher/extensions/com.github.brpaz.ulauncher-jetbrains/main.py", line 7, in <module>
    from ulauncher.api.client.Extension import Extension
  File "/nix/store/461vbpcm4vaymwn649nsgj6d0x34xg09-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/api/client/Extension.py", line 8, in <module>
    from ulauncher.api.client.Client import Client
  File "/nix/store/461vbpcm4vaymwn649nsgj6d0x34xg09-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/api/client/Client.py", line 8, in <module>
    import websocket
ModuleNotFoundError: No module named 'websocket'
2020-03-08 01:32:54,784 | ERROR | ulauncher.api.server.ExtensionRunner: _run_process() | Extension "com.github.brpaz.ulauncher-jetbrains" exited instantly with code 1

@ofborg ofborg bot requested a review from worldofpeace March 8, 2020 01:03
@aaronjanse
Copy link
Member Author

Would you mind providing reproduction steps for the websocket error? I ran nix-shell on the derivation and didn't get an error when importing websocket.

Also, I think I just fixed the XDG_DATA_DIRS issue (thank you @worldofpeace!). As a side note, why isn't xdg patched by nixpkgs to ignore entries starting with /nix/store/?

@NicolasGuilloux
Copy link

So I tried to reproduce again but on a different computer. Sadly, it is a different setup on KDE and I get different errors that block when I want to open the configuration window.

/nix/store/a376911dx3gpmflgq1d1rzpmkczba16k-ulauncher-4.4.0.r1/lib/python2.7/site-packages/ulauncher/util/image_loader.py:58: Warning: g_hash_table_lookup: assertion 'hash_table != NULL' failed
  return icon_theme.load_icon(icon_name, icon_size, Gtk.IconLookupFlags.FORCE_SIZE)
Cannot get default EGL display: EGL_BAD_PARAMETER
Cannot create EGL context: invalid display (last error: EGL_SUCCESS)
2020-03-09 10:15:44,226 | WARNING | ulauncher.util.image_loader: load_image() | Could not load image /nix/store/a376911dx3gpmflgq1d1rzpmkczba16k-ulauncher-4.4.0.r1/share/ulauncher/media/stackoverflow-icon.svg. E: gdk-pixbuf-error-quark: Impossible de reconnaître le format d’image du fichier « /nix/store/a376911dx3gpmflgq1d1rzpmkczba16k-ulauncher-4.4.0.r1/share/ulauncher/media/stackoverflow-icon.svg » (3)

The first line is when I start the application itself. The 2 lines in the middle are print in the console when I open the configuration window.

And finally the last line is related to this issue I guess: https://source.puri.sm/Librem5/OS-issues/issues/17

Tonight (french timezone), I'll try to reproduce the websocket error but it seems to appear whenever I add an extension, whatever the extension is.

@aaronjanse
Copy link
Member Author

Sorry for the delay. I'll be able to work on this tomorrow afternoon.

@aaronjanse
Copy link
Member Author

The extensions error should be fixed. I'm not sure how to resolve the pixbuf warning but everything seems to be working afaict.

@NicolasGuilloux
Copy link

Everything works well for me on Gnome, but it is still broken on my KDE. Still the same error :)

@aaronjanse
Copy link
Member Author

aaronjanse commented Mar 20, 2020

Hmm. I just installed KDE and could not reproduce the issue. Could you try deleting/moving the ulauncher state (~/.cache/ulauncher_cache, ~/.config/ulauncher) and re-installing?

@NicolasGuilloux
Copy link

I still get the same error after deleting both folders. But I start to think it is my configuration since I have issues with other GTK application. I guess there is something wrong somewhere.
If you don't reproduce, then it should be okay since it works perfectly on my Gnome :)

@worldofpeace
Copy link
Contributor

@aaronjanse I got to making the patch that does what I described 81ae12d, though it's not the best. You will get an exception if you use the package outside nixos, perhaps we can fallback to the oldcode.

@aaronjanse
Copy link
Member Author

Thank you @worldofpeace! Is there anything else that needs to be done to this PR before it's ready to be merged?

@worldofpeace
Copy link
Contributor

@aaronjanse The history just needs to be cleaned up, but I think it should be good.

@aaronjanse
Copy link
Member Author

The git history has been cleaned 👍

@worldofpeace worldofpeace merged commit bee6c1a into NixOS:master Mar 27, 2020
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