Subject: Re: [bug#50833] [PATCH] gnu: Add bower.

From: Sarah Morgensen <[email-masked]>
Date: Sun, 26 Sep 2021 18:01:20 -0700

Hi,

Thanks for the patch.  I don't use notmuch (yet) but I test-built this
and I have a few suggestions :)

jgart <[email-masked]> writes:

> * gnu/packages/mail.scm (bower): New variable.
> ---
>  gnu/packages/mail.scm | 54 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
>
> diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
> index b3bdf13537..f0624c12c4 100644
> --- a/gnu/packages/mail.scm
> +++ b/gnu/packages/mail.scm
> @@ -87,6 +87,7 @@
>    #:use-module (gnu packages file)
>    #:use-module (gnu packages fontutils)
>    #:use-module (gnu packages freedesktop)
> +  #:use-module (gnu packages gawk)
>    #:use-module (gnu packages gdb)
>    #:use-module (gnu packages gettext)
>    #:use-module (gnu packages ghostscript)
> @@ -114,6 +115,7 @@
>    #:use-module (gnu packages lua)
>    #:use-module (gnu packages m4)
>    #:use-module (gnu packages man)
> +  #:use-module (gnu packages mercury)
>    #:use-module (gnu packages ncurses)
>    #:use-module (gnu packages nettle)
>    #:use-module (gnu packages networking)
> @@ -1302,6 +1304,58 @@ agent (@dfn{MUA}) experience as an alternative to the Emacs mode shipped with
>  Notmuch.")
>      (license license:gpl3+)))
>  
> +(define-public bower
> +  (package
> +    (name "bower")
> +    (version "0.13")
> +    (home-page "https://github.com/wangp/bower")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri
> +        (git-reference
> +         (url home-page)
> +         (commit (string-append version))))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32 "0r5s16pc3ym5nd33lv9ljv1p1gpb7yysrdni4g7w7yvjrnwk35l6"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:make-flags
> +       (list
> +        "bower" "man"
> +        (string-append "CC=" ,(cc-for-target))
> +        (string-append "prefix=" %output))
> +       #:phases
> +       (modify-phases %standard-phases
> +         (delete 'configure)
> +         (replace 'check
> +           (lambda* (#:key inputs outputs tests? #:allow-other-keys)
> +             (when tests?
> +               (chdir "tests")
> +               (invoke "make"))))

Rather than chdir, you can just

  (invoke "make" "-C" "tests")

or maybe even avoid the custom phase with test-target:

  #:test-target "--directory=tests"

(Yes, it's a bit of a cheat, but test-target is just passed as the first
argument to make, and we want the default target anyway, so it works.)

> +         (replace 'install
> +           (lambda* (#:key outpus #:allow-other-keys)
> +             (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
> +                   (man (string-append (assoc-ref %outputs "out") "/share/man/man1")))
> +               (chdir "..")
> +               (install-file "bower" bin)
> +               (install-file "bower.1" man)))))))

It might be helpful to also install bower.conf.sample to "/share/bower",
so we have an example config file.

> +    (native-inputs
> +     `(("diffutils" ,diffutils) ; needed for diff command
> +       ("gawk" ,gawk)
> +       ("mercury" ,mercury)
> +       ("pandoc" ,pandoc)
> +       ("util-linux" ,util-linux))) ; needed by rev command for test_process.m
> +    (inputs
> +     `(("gpgme" ,gpgme)
> +       ("ncurses" ,ncurses)))

The README says that it also uses "base64" from coreutils, "file", and
optionally "lynx"; a grep through the source shows the following
commands used (some of them are just defaults):

base64
file

vi (used if EDITOR is not set)
lynx (used for formatting HTML messages)
xdg-open (used for opening links and MIME parts)
xclip
pandoc (used for composing multipart/alternative messages)
/usr/bin/sendmail

Other than "base64" and "file" I'm not sure which (if any) of these
should be directly linked.  "/usr/bin/sendmail" should be "sendmail" if
it's not linked, though.  "xdg-open" and "xclip" aren't available from
my PATH, but they are configurable in bower.conf, so... yeah, I'm not
sure.  Just know that without changing the bower.conf value or
installing "xdg-open", links won't open automatically.  Same for the
clipboard and reading/composing HTML messages.

If it's not possible to 'substitute*' those values, 'wrap-program' could
be used to add the correct directories to PATH, but that can introduce
other issues.

> +    (synopsis "Terminal client for the notmuch email system")
> +    (description
> +"@command{bower} is a curses frontend for the notmuch email system.
> +@command{bower} is written in mercury.")

Could you expand the description a bit, perhaps with some of the
features you quoted in your first email?  It also seems that
configurability (seen above) is another of its draws, so maybe mention
that as well :)

(Also, in my opinion "written in X" isn't relevant for end-user
packages, but I know others who would disagree, so...)

> +    (license license:gpl3+)))
> +
>  (define-public notifymuch
>    (let
>        ((commit "9d4aaf54599282ce80643b38195ff501120807f0")

Thanks again for your work! 

--
Sarah