[bug#33386,1/2] gnu: gajim: Add support for Guix packaged plugins.

Message ID 20181114195553.27293-1-clement@lassieur.org
State Accepted
Headers show
Series [bug#33386,1/2] gnu: gajim: Add support for Guix packaged plugins. | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied

Commit Message

Clément Lassieur Nov. 14, 2018, 7:55 p.m. UTC
* gnu/packages/messaging.scm (gajim)[arguments]: Add an 'add-plugin-dirs'
phase.  Export PYTHONPATH in the wrapper.
[inputs]: Remove python-axolotl and python-qrcode.
---
 gnu/packages/messaging.scm | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

Comments

Danny Milosavljevic Nov. 15, 2018, 6:19 p.m. UTC | #1
Hi Clément,

On Wed, 14 Nov 2018 20:55:52 +0100
Clément Lassieur <clement@lassieur.org> wrote:

>+         (add-after 'unpack 'add-plugin-dirs
>+           (lambda _
>+             (substitute* "gajim/common/configpaths.py"
>+               (("_paths\\['PLUGINS_USER'\\]")
>+                (string-append
>+                 "_paths['PLUGINS_USER'],os.path.expanduser"
>+                 "('~/.guix-profile/share/gajim/plugins')")))
>+             #t))

[...]

> +                        (pythonpath (string-append
> +                                     "$HOME/.guix-profile/lib/python"
> +                                     ,(version-major+minor
> +                                       (package-version python))
> +                                     "/site-packages")))


Hmm, don't both of these hard-code one profile?  I thought one can use
any number of profiles - and this patch could definitely pick from the
wrong one.  Why isn't the PLUGINS_USER setting enough?  Can't it be
provided via environment variables?  (set by the profile)

Also, shouldn't PYTHONPATH already have been set by the profile?  For me,
it is set (to ~/.guix-profile/lib/python3.6/site-packages) when I log in.
Clément Lassieur Nov. 16, 2018, 10:13 a.m. UTC | #2
Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi Clément,
>
> On Wed, 14 Nov 2018 20:55:52 +0100
> Clément Lassieur <clement@lassieur.org> wrote:
>
>>+         (add-after 'unpack 'add-plugin-dirs
>>+           (lambda _
>>+             (substitute* "gajim/common/configpaths.py"
>>+               (("_paths\\['PLUGINS_USER'\\]")
>>+                (string-append
>>+                 "_paths['PLUGINS_USER'],os.path.expanduser"
>>+                 "('~/.guix-profile/share/gajim/plugins')")))
>>+             #t))
>
> [...]
>
>> +                        (pythonpath (string-append
>> +                                     "$HOME/.guix-profile/lib/python"
>> +                                     ,(version-major+minor
>> +                                       (package-version python))
>> +                                     "/site-packages")))
>
>
> Hmm, don't both of these hard-code one profile?

I don't understand what this means.

> I thought one can use any number of profiles - and this patch could
> definitely pick from the wrong one.

What do you mean?  This patch just adds the Guix packaged plugins to the
list of plugin dirs.

> Why isn't the PLUGINS_USER setting enough?

Because it doens't know about Guix installed plugins.  It doesn't look
in ~/.guix-profile/whatever.  Only at /gnu/store/...-gajim/something and
~/.local/share/gajim/something.

> Can't it be provided via environment variables?  (set by the profile)

Gajim doesn't seem to support customizing plugin dirs through
environment variables, which is why I edited its code.

> Also, shouldn't PYTHONPATH already have been set by the profile?  For
> me, it is set (to ~/.guix-profile/lib/python3.6/site-packages) when I
> log in.

It shouldn't be in the profile if python isn't installed.

Clément
Danny Milosavljevic Nov. 18, 2018, 11:15 p.m. UTC | #3
Hi Clément,

> I don't understand what this means.
> > I thought one can use any number of profiles - and this patch could
> > definitely pick from the wrong one.  
> 
> What do you mean?  This patch just adds the Guix packaged plugins to the
> list of plugin dirs.

guix supports any number of profiles as one user, the ~/.guix-profile one is just
the default, you can create and select profiles at will.

You can specify any profile you want using the option "-p" to "guix package" -
also, "guix environment" will create a custom profile.

However, your patch hardcodes ~/.guix-profile which is in general not what a user
using "-p" would want.  I agree that it makes sense to search for the plugins in
the current profile, but it's not clear to me that ~/.guix-profile is always
guaranteed to BE the current profile.  Is it?

According to https://www.gnu.org/software/guix/manual/en/html_node/Invoking-guix-environment.html#FOOT16 ,
fontconfig already hardcodes ~/.guix-profile and "guix environment" has a
special flag to fake it, so maybe (probably?) it's OK to use it after all.

I hope someone else can chime in - but this is what immediately caught my
eye because what's the use of all these environment variables if one
hard-codes ~/.guix-profile anyway - could have hard-coded it in all packages,
then...

> > Why isn't the PLUGINS_USER setting enough?  
> 
> Because it doens't know about Guix installed plugins.  It doesn't look
> in ~/.guix-profile/whatever.  Only at /gnu/store/...-gajim/something and
> ~/.local/share/gajim/something.
> 
> > Can't it be provided via environment variables?  (set by the profile)  
> 
> Gajim doesn't seem to support customizing plugin dirs through
> environment variables, which is why I edited its code.

In general that's OK.

> > Also, shouldn't PYTHONPATH already have been set by the profile?  For
> > me, it is set (to ~/.guix-profile/lib/python3.6/site-packages) when I
> > log in.  
> 
> It shouldn't be in the profile if python isn't installed.

Oh, makes sense.
Clément Lassieur Nov. 19, 2018, 4:02 p.m. UTC | #4
Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi Clément,
>
>> I don't understand what this means.
>> > I thought one can use any number of profiles - and this patch could
>> > definitely pick from the wrong one.  
>> 
>> What do you mean?  This patch just adds the Guix packaged plugins to the
>> list of plugin dirs.
>
> guix supports any number of profiles as one user, the ~/.guix-profile one is just
> the default, you can create and select profiles at will.
>
> You can specify any profile you want using the option "-p" to "guix package" -
> also, "guix environment" will create a custom profile.
>
> However, your patch hardcodes ~/.guix-profile which is in general not what a user
> using "-p" would want.  I agree that it makes sense to search for the plugins in
> the current profile, but it's not clear to me that ~/.guix-profile is always
> guaranteed to BE the current profile.  Is it?
>
> According to https://www.gnu.org/software/guix/manual/en/html_node/Invoking-guix-environment.html#FOOT16 ,
> fontconfig already hardcodes ~/.guix-profile and "guix environment" has a
> special flag to fake it, so maybe (probably?) it's OK to use it after all.
>
> I hope someone else can chime in - but this is what immediately caught my
> eye because what's the use of all these environment variables if one
> hard-codes ~/.guix-profile anyway - could have hard-coded it in all packages,
> then...

Understood, thanks for this nice explanation!

I attached a new patch.  What do you think?

Thanks,
Clément
Clément Lassieur Dec. 11, 2018, 10:22 a.m. UTC | #5
Clément Lassieur <clement@lassieur.org> writes:

> Danny Milosavljevic <dannym@scratchpost.org> writes:
>
>> Hi Clément,
>>
>>> I don't understand what this means.
>>> > I thought one can use any number of profiles - and this patch could
>>> > definitely pick from the wrong one.  
>>> 
>>> What do you mean?  This patch just adds the Guix packaged plugins to the
>>> list of plugin dirs.
>>
>> guix supports any number of profiles as one user, the ~/.guix-profile one is just
>> the default, you can create and select profiles at will.
>>
>> You can specify any profile you want using the option "-p" to "guix package" -
>> also, "guix environment" will create a custom profile.
>>
>> However, your patch hardcodes ~/.guix-profile which is in general not what a user
>> using "-p" would want.  I agree that it makes sense to search for the plugins in
>> the current profile, but it's not clear to me that ~/.guix-profile is always
>> guaranteed to BE the current profile.  Is it?
>>
>> According to https://www.gnu.org/software/guix/manual/en/html_node/Invoking-guix-environment.html#FOOT16 ,
>> fontconfig already hardcodes ~/.guix-profile and "guix environment" has a
>> special flag to fake it, so maybe (probably?) it's OK to use it after all.
>>
>> I hope someone else can chime in - but this is what immediately caught my
>> eye because what's the use of all these environment variables if one
>> hard-codes ~/.guix-profile anyway - could have hard-coded it in all packages,
>> then...
>
> Understood, thanks for this nice explanation!
>
> I attached a new patch.  What do you think?

I pushed it.  I'll be happy to improve it if you have other comments.

Thanks,
Clément

Patch

diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index c22cacfd3..f68b7e4eb 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -588,15 +588,29 @@  was initially a fork of xmpppy, but uses non-blocking sockets.")
      `(#:test-target "test_nogui"
        #:phases
        (modify-phases %standard-phases
+         (add-after 'unpack 'add-plugin-dirs
+           (lambda _
+             (substitute* "gajim/common/configpaths.py"
+               (("_paths\\['PLUGINS_USER'\\]")
+                (string-append
+                 "_paths['PLUGINS_USER'],os.path.expanduser"
+                 "('~/.guix-profile/share/gajim/plugins')")))
+             #t))
          (add-after 'install 'wrap-program
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (for-each
                 (lambda (name)
                   (let ((file (string-append out "/bin/" name))
-                        (gi-typelib-path (getenv "GI_TYPELIB_PATH")))
+                        (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
+                        (pythonpath (string-append
+                                     "$HOME/.guix-profile/lib/python"
+                                     ,(version-major+minor
+                                       (package-version python))
+                                     "/site-packages")))
                     (wrap-program file
-                      `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path)))))
+                      `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
+                      `("PYTHONPATH" ":" prefix (,pythonpath)))))
                 '("gajim" "gajim-remote" "gajim-history-manager")))
              #t))
          (add-after 'install 'install-icons
@@ -636,7 +650,6 @@  was initially a fork of xmpppy, but uses non-blocking sockets.")
        ("gtkspell3" ,gtkspell3)
        ("hicolor-icon-theme" ,hicolor-icon-theme)
        ("libsecret" ,libsecret)
-       ("python-axolotl" ,python-axolotl)
        ("python-cssutils" ,python-cssutils)
        ("python-dbus" ,python-dbus)
        ("python-gnupg" ,python-gnupg)
@@ -646,8 +659,7 @@  was initially a fork of xmpppy, but uses non-blocking sockets.")
        ("python-precis-i18n" ,python-precis-i18n)
        ("python-pycairo" ,python-pycairo)
        ("python-pygobject" ,python-pygobject)
-       ("python-pyopenssl" ,python-pyopenssl)
-       ("python-qrcode" ,python-qrcode)))
+       ("python-pyopenssl" ,python-pyopenssl)))
     (home-page "https://gajim.org/")
     (synopsis "Jabber (XMPP) client")
     (description "Gajim is a feature-rich and easy to use Jabber/XMPP client.