Patchwork [2/6] build-system/emacs: Use "emacs" from native-inputs if specified.

login
register
mail settings
Submitter Alex Kost
Date May 16, 2016, 6:20 p.m.
Message ID <1463422824-7161-3-git-send-email-alezost@gmail.com>
Download mbox | patch
Permalink /patch/12291/
State New
Headers show

Comments

Alex Kost - May 16, 2016, 6:20 p.m.
* guix/build-system/emacs.scm (lower): Do not add "emacs" to
  build-inputs if it is already specified in the native-inputs.
---
 guix/build-system/emacs.scm | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
Ludovic Courtès - May 19, 2016, 11:54 a.m.
Alex Kost <alezost@gmail.com> skribis:

> * guix/build-system/emacs.scm (lower): Do not add "emacs" to
>   build-inputs if it is already specified in the native-inputs.

In theory, one could want to have Emacs both in ‘native-inputs’ (to
build .elc files, for instance) and in ‘inputs’ (for instance because
the program embeds a reference to the ‘emacs’ program.)

So I’m rather reluctant about this approach.

Did you find packages where Emacs wrongfully appears twice in the
inputs?  It might be best to fix those packages instead.

WDYT?

Thanks,
Ludo’.
Alex Kost - May 20, 2016, 9:21 p.m.
Ludovic Courtès (2016-05-19 14:54 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> * guix/build-system/emacs.scm (lower): Do not add "emacs" to
>>   build-inputs if it is already specified in the native-inputs.
>
> In theory, one could want to have Emacs both in ‘native-inputs’ (to
> build .elc files, for instance) and in ‘inputs’ (for instance because
> the program embeds a reference to the ‘emacs’ program.)

I don't see a problem here, if "emacs" should be added to inputs, it may
just go there.  Nothing prohibits it.

> So I’m rather reluctant about this approach.
>
> Did you find packages where Emacs wrongfully appears twice in the
> inputs?  It might be best to fix those packages instead.

Do you mean: appears both in "inputs" and "native-inputs"?  If so, then
no, there are no such packages.

But I don't understand how this concerns.  The purpose of this patch is
to allow us to use a different "emacs" to build emacs packages.  I
would say this is the core patch of the whole patchset.  I didn't like
the fact that emacs-build-system uses a full-featured (and heavy on
dependencies) "emacs" package, and I would like to use "emacs-minimal"
instead.  But for some rare cases (currently only for auctex),
"emacs-minimal" (or "emacs-no-x") is not enough, so it should be
substituted somehow.  That's why I made this patch.

Patch

diff --git a/guix/build-system/emacs.scm b/guix/build-system/emacs.scm
index 03c1eb2..017e6ef 100644
--- a/guix/build-system/emacs.scm
+++ b/guix/build-system/emacs.scm
@@ -1,5 +1,6 @@ 
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
+;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -25,6 +26,7 @@ 
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
   #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (%emacs-build-system-modules
             emacs-build
@@ -73,8 +75,16 @@ 
 
                         ;; Keep the standard inputs of 'gnu-build-system'.
                         ,@(standard-packages)))
-         (build-inputs `(("emacs" ,emacs)
-                         ,@native-inputs))
+         ;; Add emacs to build-inputs only if native-inputs do not contain
+         ;; emacs already.  This allows us to use non-default emacs for
+         ;; building.
+         (build-inputs (if (find (match-lambda
+                                   (("emacs" _ ...) #t)
+                                   (_ #f))
+                                 native-inputs)
+                           native-inputs
+                           `(("emacs" ,emacs)
+                             ,@native-inputs)))
          (outputs outputs)
          (build emacs-build)
          (arguments (strip-keyword-arguments private-keywords arguments)))))