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

nautilus-python not loading python-extension #126074

Closed
Stunkymonkey opened this issue Jun 7, 2021 · 8 comments
Closed

nautilus-python not loading python-extension #126074

Stunkymonkey opened this issue Jun 7, 2021 · 8 comments
Labels
0.kind: bug 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: python

Comments

@Stunkymonkey
Copy link
Contributor

Describe the bug
nautilus-python does not load python-extension of nautilus to display a context menu entry.

To Reproduce
Steps to reproduce the behavior:

  1. install gnomeExtensions.nautilus-open-any-terminal from Stunkymonkey@da1610b
  2. restart nautilus
  3. no context menu is shown

Expected behavior
a new context menu entry, that could open e.g. alacritty

Additional context
Maybe I am doing something wrong. I am pretty new to nix. Maybe you could help

Notify maintainers
i guess @hedning, @dasj19, @maxeaubrey

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 5.12.4, NixOS, 21.05.804.5de44c15758 (Okapi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.12`
 - channels(user): `""`
 - channels(root): `"nixos-21.05.804.5de44c15758, nixos-unstable-21.05pre277486.f5e8bdd07d1"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixos modules affected by the problem
module: gnomeExtensions.nautilus-open-any-terminal
@veprbl veprbl added 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: python labels Jun 18, 2021
@dasj19
Copy link
Contributor

dasj19 commented Aug 22, 2021

Idk how much help this is but have you tried looking at how nautilus-python is defined: https://github.com/NixOS/nixpkgs/blob/master/pkgs/desktops/gnome/misc/nautilus-python/default.nix

I think that the following line specifically says that only extensions in $out/lib/nautilus/extensions-3.0 are loaded.
PKG_CONFIG_LIBNAUTILUS_EXTENSION_EXTENSIONDIR = "${placeholder "out"}/lib/nautilus/extensions-3.0";

@Stunkymonkey
Copy link
Contributor Author

tried it, but does not work.
additionally i found mat2 which tries to do the same thing. unfortunately it does not work as well.

@jtojnar
Copy link
Member

jtojnar commented Jan 29, 2022

nautilus-python did not work properly before #142824.


We rely on GNOME NixOS module setting NAUTILUS_EXTENSION_DIR environment variable for Nautilus to be find nautilus-python. That means nautilus-python needs to be installed via environment.systemPackages.

nautilus-python then needs its extensions to be available on XDG_DATA_DIRS path (in nautilus-python/extensions subdirectory). And it might fail if the extension depends on anything other than Nautilus and its dependencies.

@Stunkymonkey
Copy link
Contributor Author

thanks for the expanation 👍 .
can you confirm, that mat2 is working? (right-clicking on jpegs, mp3s, ... should have an extra entry about removing metadata)
I have gnome.nautilus-python installed system-wide. But still do not see the context-menu.

If you have a second please look over my last commit: https://github.com/Stunkymonkey/nixpkgs/tree/nautilus-open-any-terminal

@jtojnar
Copy link
Member

jtojnar commented Jan 29, 2022

Running nautilus in the console shows the following with mat2 installed:

Traceback (most recent call last):
  File "/home/jtojnar/.nix-profile/share/nautilus-python/extensions/mat2.py", line 28, in <module>
    from libmat2 import parser_factory
  File "/nix/store/x7rfd5lxym1zx7m15yhk0i6hlbfr4cwd-python3.9-mat2-0.12.3/lib/python3.9/site-packages/libmat2/parser_factory.py", line 30, in <module>
    __load_all_parsers()
  File "/nix/store/x7rfd5lxym1zx7m15yhk0i6hlbfr4cwd-python3.9-mat2-0.12.3/lib/python3.9/site-packages/libmat2/parser_factory.py", line 27, in __load_all_parsers
    importlib.import_module('.' + name, package='libmat2')
  File "/nix/store/gras7a25yy9f7djmzrgh1bsiiacg0s9c-python3-3.9.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/nix/store/x7rfd5lxym1zx7m15yhk0i6hlbfr4cwd-python3.9-mat2-0.12.3/lib/python3.9/site-packages/libmat2/images.py", line 6, in <module>
    import cairo
ModuleNotFoundError: No module named 'cairo'

so that is an issue with extra dependencies (python3.pkgs.pycairo). I guess the best solution would be manipulating python path in mat2 like python wrappers do.

@Stunkymonkey
Copy link
Contributor Author

my first goal will be to get the same error for mat2 as you do. Because i never managed to get nautilus-python source any files.

i have nautilus-python and mat2 both installed.

Do I have to set NAUTILUS_EXTENSION_DIR like this?

NAUTILUS_EXTENSION_DIR=$(nix-store --query --requisites /run/current-system | grep "nautilus-python-1.2.3$")/lib/nautilus/extensions-3.0 nautilus

or is like this?

XDG_DATA_DIRS=$(nix-store --query --requisites /run/current-system | grep "mat2")/share/nautilus-python/extensions:$XDG_DATA_DIRS nautilus

sorry I am a bit lost here 🙈

@jtojnar
Copy link
Member

jtojnar commented Jan 31, 2022

NAUTILUS_EXTENSION_DIR can only contain a single directory. And that should be /run/current-system/sw/lib/nautilus/extensions-3.0, where all the Nautilus extensions are symlinked thanks to environment.systemPackages:

environment.sessionVariables.NAUTILUS_EXTENSION_DIR = "${config.system.path}/lib/nautilus/extensions-3.0";

XDG_DATA_DIRS should contain /run/current-system/sw/share on NixOS by default (note that it only contains the share/ directory. If you do not use GNOME, you might also need environment.pathsToLink so that environment.systemPackages creates a symlink.

But yeah, something like the following should work:

env "NAUTILUS_EXTENSION_DIR=$(nix-build -A gnome.nautilus-python --no-out-link)/lib/nautilus/extensions-3.0" "XDG_DATA_DIRS=$(nix-build -A mat2 --no-out-link)/share:$XDG_DATA_DIRS" nautilus

@Stunkymonkey
Copy link
Contributor Author

If you do not use GNOME, you might also need environment.pathsToLink so that environment.systemPackages creates a symlink.

this was exactly my problem. by adding this the extensions will get loaded. Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: python
Projects
None yet
Development

No branches or pull requests

4 participants