Subject: [bug#50077] [PATCH 1/3] gnu: notmuch: Add separate 'emacs' output.

From: Andrew Tropin <[email-masked]>
Date: Mon, 30 Aug 2021 10:14:46 +0300

On 2021-08-28 12:34, Xinglu Chen wrote:

> [ Debbugs wasn’t Cc’d in the previous message ]
>

Oops)

>
> On Mon, Aug 23 2021, Andrew Tropin wrote:
>
>> On 2021-08-16 16:12, Xinglu Chen wrote:
>>
>>> * gnu/packages/mail.scm (notmuch)[outputs]: Add ‘emacs’ output
>>> [arguments]<#:modules>: Add (guix build emacs-utils).
>>> <#:phases>{configure}: Use the ‘emacs’ output.
>>> {make-autoloads}: Modify the default ‘make-autoloads’ phase to use the ‘emacs’
>>> output.
>>> ---
>>>  gnu/packages/mail.scm | 16 +++++++++++++---
>>>  1 file changed, 13 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
>>> index ccf44b7cf3..bbc616f6f5 100644
>>> --- a/gnu/packages/mail.scm
>>> +++ b/gnu/packages/mail.scm
>>> @@ -1337,7 +1337,8 @@ invoking @command{notifymuch} from the post-new hook.")
>>>      (arguments
>>>       `(#:modules ((guix build gnu-build-system)
>>>                    ((guix build emacs-build-system) #:prefix emacs:)
>>> -                  (guix build utils))
>>> +                  (guix build utils)
>>> +                  (guix build emacs-utils))
>>>         #:imported-modules (,@%gnu-build-system-modules
>>>                             (guix build emacs-build-system)
>>>                             (guix build emacs-utils))
>>> @@ -1355,7 +1356,8 @@ invoking @command{notifymuch} from the post-new hook.")
>>>                        (setenv "CONFIG_SHELL" (which "sh"))
>>>  
>>>                        (let* ((out (assoc-ref outputs "out"))
>>> -                             (elisp (emacs:elpa-directory out)))
>>> +                             (emacs (assoc-ref outputs "emacs"))
>>> +                             (elisp (emacs:elpa-directory emacs)))
>>>                          (invoke "./configure"
>>>                                  (string-append "--prefix=" out)
>>>                                  (string-append "--emacslispdir=" elisp)
>>> @@ -1373,7 +1375,14 @@ invoking @command{notifymuch} from the post-new hook.")
>>>                        (substitute* (find-files "test" "\\.sh$")
>>>                          (("/bin/sh") (which "sh")))))
>>>                    (add-after 'install 'make-autoloads
>>> -                    (assoc-ref emacs:%standard-phases 'make-autoloads)))))
>>> +                    (lambda* (#:key outputs inputs #:allow-other-keys)
>>> +                      (let* ((emacs (string-append (assoc-ref inputs "emacs") "/bin/emacs"))
>>> +                             (out (assoc-ref outputs "emacs"))
>>> +                             (elpa-name-ver ((@@ (guix build emacs-build-system)
>>> +                                                 store-directory->elpa-name-version) out))
>>> +                             (elpa-name (package-name->name+version elpa-name-ver))
>>> +                             (el-dir (emacs:elpa-directory out)))
>>> +                        (emacs-generate-autoloads elpa-name el-dir)))))))
>>>      (native-inputs
>>>       `(("bash-completion" ,bash-completion)
>>>         ("emacs" ,emacs-no-x)    ; -minimal lacks libxml, needed for some tests
>>> @@ -1394,6 +1403,7 @@ invoking @command{notifymuch} from the post-new hook.")
>>>         ("talloc" ,talloc)
>>>         ("xapian" ,xapian)
>>>         ("zlib" ,zlib)))
>>> +    (outputs '("out" "emacs"))
>>>      (home-page "https://notmuchmail.org/")
>>>      (synopsis "Thread-based email index, search, and tagging")
>>>      (description
>>
>> The separate output is ok, but I think making a separate emacs-notmuch
>> package looks more consistent.  We can inherit it from notmuch package
>> to be sure that the packages are built from the same source code.
>
> Why would it be more consistent to make a separate package?  Making a
> separate package is usually used for packaging a slightly different
> version of the “regular” package, e.g., ‘emacs-next-pgtk’ adds native
> compilation and pure GTK support for Emacs., ‘emacs-no-x’ removes X
> suport for ‘emacs’.  ‘emacs-notmuch’ isn’t really a different version of
> ‘notmuch’, it’s just ‘notmuch’ but with all the non-Elisp stuff
> removed.  This is usually what using different outputs tries to achieve,
> e.g., separate documentation from the main package, or in this case,
> separate Elisp stuff from the main package.
>

Almost all elisp packages in Guix have a emacs- prefix, so as a user I
expect to find notmuch*.el in emacs-notmuch package and notmuch binary
in notmuch package, despite the fact that upstream distributes the
source code for both of them in one tarball.  Moreover, with
emacs-notmuch and notmuch packages it's possible to use different build
systems, which helps in automated package modification, for example I
want to native compile all emacs packages or generate some additional
metainformation, I just find all packages in my profile with
emacs-build-system and modify phases accordingly.  Yes, it's possible to
do such modification for other packages manually, but it feels hacky and
inconvinient.

The separate output can work, but a separate package looks better to me.

P.S. I know that there are some emacs packages in Guix already, which
doesn't use emacs-build-system, but I think we should keep that number
as low as possible and ideally to make it equal to 0 =)

> 
> The ‘notmuch’ package in Nixpkgs also uses multiple outputs[1], which
> I think makes sense.
>
> <https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/mailreaders/notmuch/default.nix>
>>
>> Thank you for working on this, the changes are good and useful!)
>
> You are welcome!  :-)