diff mbox series

[bug#45190,1/1] gnu: Add pinentry-rofi.

Message ID 20201212023103.79992-1-plattfot@posteo.net
State Accepted
Headers show
Series Add pinentry-rofi | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Fredrik Salomonsson Dec. 12, 2020, 2:31 a.m. UTC
* gnu/packages/gnupg.scm (pinentry-rofi): New variable.
---
 gnu/packages/gnupg.scm | 81 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

Comments

Ludovic Courtès Jan. 3, 2021, 9:18 p.m. UTC | #1
Hi Fredrik,

Fredrik Salomonsson <plattfot@posteo.net> skribis:

> * gnu/packages/gnupg.scm (pinentry-rofi): New variable.

Overall LGTM, with some minor issues highlighted below:

> +(define-public pinentry-rofi
> +  (package
> +  (name "pinentry-rofi")

Indentation is off here (should be offset by two).

> +  (arguments
> +    `(#:strip-binaries? #f ;; Has no binaries and the strip phase is failing

Hmm the ‘strip’ phase should not fail.  Are you sure this is necessary?

> +      #:phases
> +      (modify-phases
> +        %standard-phases
> +        (add-after
> +          'install
> +          'hall-wrap-binaries

Nitpick: please indent as in other files.

> +          (lambda* (#:key inputs outputs #:allow-other-keys)
> +            (let* ((compiled-dir
> +                     (lambda (out version)
> +                       (string-append out "/lib/guile/" version "/site-ccache")))
> +                   (uncompiled-dir
> +                     (lambda (out version)
> +                       (string-append
> +                         out
> +                         "/share/guile/site"
> +                         (if (string-null? version) "" "/")
> +                         version)))
> +                   (dep-path
> +                     (lambda (env modules path)
> +                       (list env
> +                             ":"
> +                             'prefix
> +                             (cons modules
> +                                   (map (lambda (input)
> +                                          (string-append
> +                                            (assoc-ref inputs input)
> +                                            path))
> +                                        ,''("rofi"))))))
> +                   (out (assoc-ref outputs "out"))
> +                   (bin (string-append out "/bin/"))
> +                   (site (uncompiled-dir out "")))
> +              (match (scandir site)
> +                     (("." ".." version)
> +                      (for-each
> +                        (lambda (file)
> +                          (wrap-program
> +                            (string-append bin file)
> +                            (dep-path
> +                              "GUILE_LOAD_PATH"
> +                              (uncompiled-dir out version)
> +                              (uncompiled-dir "" version))
> +                            (dep-path
> +                              "GUILE_LOAD_COMPILED_PATH"
> +                              (compiled-dir out version)
> +                              (compiled-dir "" version))))
> +                        ,''("pinentry-rofi"))
> +                      #t))))))))

Since I think you’re also upstream :-), how about adding something like
that at the top of the installed executable:

  (eval-when (load expand eval)
    (set! %load-path (cons "@moddir@" %load-path))
    (set! %laod-compiled-path (cons "@godir@" %load-compiled-path)))

?

> +  (propagated-inputs `(("rofi" ,rofi)))

It’s best to avoid propagating.  Perhaps you can replace the “rofi”
string in ‘pinentry-rofi’ by “/gnu/store/…/bin/rofi” in a post-install
phase?

> +  (synopsis "Rofi GUI for GnuPG's passphrase input")
> +  (description "Simple pinentry GUI using rofi that allows users to enter a
> +passphrase when required by @code{gpg} or other software.")

Please make it a full sentence.  Also, to give context, perhaps replace
“rofi” by “the Rofi application launcher”.

Could you send an updated patch?

Thanks in advance and sorry for the delay!

Ludo’.
Fredrik Salomonsson Jan. 9, 2021, 2:14 a.m. UTC | #2
Hi Ludovic,

Ludovic Courtès <ludo@gnu.org> writes:

>> +(define-public pinentry-rofi
>> +  (package
>> +  (name "pinentry-rofi")
>
> Indentation is off here (should be offset by two).

Fixed in v2.

>> +  (arguments
>> +    `(#:strip-binaries? #f ;; Has no binaries and the strip phase is failing
>
> Hmm the ‘strip’ phase should not fail.  Are you sure this is necessary?

It was failing with a warning as there are no binaries to strip. But
it's not an error so I removed this in v2.

>> +      #:phases
>> +      (modify-phases
>> +        %standard-phases
>> +        (add-after
>> +          'install
>> +          'hall-wrap-binaries
>
> Nitpick: please indent as in other files.

Fixed in v2.

> Since I think you’re also upstream :-), how about adding something like
> that at the top of the installed executable:
>
>   (eval-when (load expand eval)
>     (set! %load-path (cons "@moddir@" %load-path))
>     (set! %laod-compiled-path (cons "@godir@" %load-compiled-path)))
>
> ?

Yup, I'm upstream as well. I don't mind adding that, just need to know
what it solves :). I'm guessing that it removes the need to wrap the
executable, is that correct?

And are the "@moddir@" and "@godir@" expected to be expanded by
automake? I tested to just add it in the source code and automake did
nothing with them.

For now I left it out in v2 as I'm a bit unsure of it.

>> +  (propagated-inputs `(("rofi" ,rofi)))

> It’s best to avoid propagating.  Perhaps you can replace the “rofi”
> string in ‘pinentry-rofi’ by “/gnu/store/…/bin/rofi” in a post-install
> phase?

Is there a rule of thumb or something to know when to use propagating
inputs? I'm a bit confused when to use is it. Is it just when dealing
with libraries? What are the downsides of using propagating inputs?
Apologize if this is already mentioned in the manual. Only sections I
could find that mentions propagated inputs are section 5.2 and 8.2.1.

Anyway this is fixed in v2, I added the rofi's binary path to PATH for
the wrapper of pinentry-rofi. 

>> +  (synopsis "Rofi GUI for GnuPG's passphrase input")
>> +  (description "Simple pinentry GUI using rofi that allows users to enter a
>> +passphrase when required by @code{gpg} or other software.")
>
> Please make it a full sentence.  Also, to give context, perhaps replace
> “rofi” by “the Rofi application launcher”.

I fleshed out the description in v2, let me know if it sounds better.

> Could you send an updated patch?

All updates should be in PATCH v2

> Thanks in advance and sorry for the delay!

Thank you for reviewing my patch and no worries about the delay.
Ludovic Courtès Jan. 13, 2021, 3:24 p.m. UTC | #3
Hi,

Fredrik Salomonsson <plattfot@posteo.net> skribis:

>>> +  (arguments
>>> +    `(#:strip-binaries? #f ;; Has no binaries and the strip phase is failing
>>
>> Hmm the ‘strip’ phase should not fail.  Are you sure this is necessary?
>
> It was failing with a warning as there are no binaries to strip. But
> it's not an error so I removed this in v2.

Right, it’s just a warning, due to the fact that .go files are ELF but
the ‘strip’ command doesn’t know what to do with them.

>> Since I think you’re also upstream :-), how about adding something like
>> that at the top of the installed executable:
>>
>>   (eval-when (load expand eval)
>>     (set! %load-path (cons "@moddir@" %load-path))
>>     (set! %laod-compiled-path (cons "@godir@" %load-compiled-path)))
>>
>> ?
>
> Yup, I'm upstream as well. I don't mind adding that, just need to know
> what it solves :). I'm guessing that it removes the need to wrap the
> executable, is that correct?
>
> And are the "@moddir@" and "@godir@" expected to be expanded by
> automake? I tested to just add it in the source code and automake did
> nothing with them.

It’s replaced provided ‘configure.ac’ defines them and AC_SUBSTs them,
along these lines (here they have a longer name):

  https://notabug.org/guile-zstd/guile-zstd/src/master/configure.ac#L43

>> It’s best to avoid propagating.  Perhaps you can replace the “rofi”
>> string in ‘pinentry-rofi’ by “/gnu/store/…/bin/rofi” in a post-install
>> phase?
>
> Is there a rule of thumb or something to know when to use propagating
> inputs? I'm a bit confused when to use is it. Is it just when dealing
> with libraries? What are the downsides of using propagating inputs?
> Apologize if this is already mentioned in the manual. Only sections I
> could find that mentions propagated inputs are section 5.2 and 8.2.1.

In general, propagated inputs should be avoided as they “pollute” the
user’s profile (you install X and find yourself with X, Y, and Z).

The preferred method in situations like this is to patch the source so
it uses absolute file names for commands.

Thanks for sending an updated patch!

Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index 3620efea3a..dad6a1de81 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -17,6 +17,7 @@ 
 ;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2020 Fredrik Salomonsson <plattfot@posteo.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -67,6 +68,7 @@ 
   #:use-module (gnu packages tor)
   #:use-module (gnu packages web)
   #:use-module (gnu packages xorg)
+  #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xml)
   #:use-module (guix packages)
   #:use-module (guix download)
@@ -892,6 +894,85 @@  passphrase when @code{gpg} is run and needs it.")))
 @dfn{Enlightenment Foundation Libraries} (EFL) that allows users to enter a
 passphrase when @code{gpg} is run and needs it.")))
 
+(define-public pinentry-rofi
+  (package
+  (name "pinentry-rofi")
+  (version "2.0.1")
+  (source (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://github.com/plattfot/pinentry-rofi/")
+                  (commit version)))
+            (file-name (git-file-name name version))
+            (sha256
+             (base32 "044bnldz7k74s873jwsjgff176l1jsvpbaka7d1wcj8b5pwqv2av"))))
+  (build-system gnu-build-system)
+  (arguments
+    `(#:strip-binaries? #f ;; Has no binaries and the strip phase is failing
+      #:modules
+      ((ice-9 match)
+       (ice-9 ftw)
+       ,@%gnu-build-system-modules)
+      #:phases
+      (modify-phases
+        %standard-phases
+        (add-after
+          'install
+          'hall-wrap-binaries
+          (lambda* (#:key inputs outputs #:allow-other-keys)
+            (let* ((compiled-dir
+                     (lambda (out version)
+                       (string-append out "/lib/guile/" version "/site-ccache")))
+                   (uncompiled-dir
+                     (lambda (out version)
+                       (string-append
+                         out
+                         "/share/guile/site"
+                         (if (string-null? version) "" "/")
+                         version)))
+                   (dep-path
+                     (lambda (env modules path)
+                       (list env
+                             ":"
+                             'prefix
+                             (cons modules
+                                   (map (lambda (input)
+                                          (string-append
+                                            (assoc-ref inputs input)
+                                            path))
+                                        ,''("rofi"))))))
+                   (out (assoc-ref outputs "out"))
+                   (bin (string-append out "/bin/"))
+                   (site (uncompiled-dir out "")))
+              (match (scandir site)
+                     (("." ".." version)
+                      (for-each
+                        (lambda (file)
+                          (wrap-program
+                            (string-append bin file)
+                            (dep-path
+                              "GUILE_LOAD_PATH"
+                              (uncompiled-dir out version)
+                              (uncompiled-dir "" version))
+                            (dep-path
+                              "GUILE_LOAD_COMPILED_PATH"
+                              (compiled-dir out version)
+                              (compiled-dir "" version))))
+                        ,''("pinentry-rofi"))
+                      #t))))))))
+  (native-inputs
+    `(("autoconf" ,autoconf)
+      ("automake" ,automake)
+      ("pkg-config" ,pkg-config)
+      ("texinfo" ,texinfo)))
+  (inputs `(("guile" ,guile-3.0)))
+  (propagated-inputs `(("rofi" ,rofi)))
+  (synopsis "Rofi GUI for GnuPG's passphrase input")
+  (description "Simple pinentry GUI using rofi that allows users to enter a
+passphrase when required by @code{gpg} or other software.")
+  (home-page "https://github.com/plattfot/pinentry-rofi/")
+  (license license:gpl3+)))
+
 (define-public pinentry
   (package (inherit pinentry-gtk2)
     (name "pinentry")))