1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix build-system emacs)
20 #:use-module (guix store)
21 #:use-module (guix utils)
22 #:use-module (guix packages)
23 #:use-module (guix derivations)
24 #:use-module (guix search-paths)
25 #:use-module (guix build-system)
26 #:use-module (guix build-system gnu)
27 #:use-module (ice-9 match)
28 #:use-module (srfi srfi-26)
29 #:export (%emacs-build-system-modules
35 ;; Standard build procedure for Emacs packages. This is implemented as an
36 ;; extension of 'gnu-build-system'.
40 (define %emacs-build-system-modules
41 ;; Build-side modules imported by default.
42 `((guix build emacs-build-system)
43 (guix build emacs-utils)
44 ,@%gnu-build-system-modules))
46 (define (default-emacs)
47 "Return the default Emacs package."
48 ;; Lazily resolve the binding to avoid a circular dependency.
49 (let ((emacs-mod (resolve-interface '(gnu packages emacs))))
50 ;; we use 'emacs' instead of 'emacs-no-x' because the latter appears not
51 ;; to be loading some macros and causes problems to some packages. For
52 ;; example, with the latter AUCTeX gives the error message:
53 ;; "(invalid-function dbus-ignore-errors)".
54 (module-ref emacs-mod 'emacs)))
57 #:key source inputs native-inputs outputs system target
58 (emacs (default-emacs))
61 "Return a bag for NAME."
62 (define private-keywords
63 '(#:target #:emacs #:inputs #:native-inputs))
65 (and (not target) ;XXX: no cross-compilation
69 (host-inputs `(,@(if source
74 ;; Keep the standard inputs of 'gnu-build-system'.
75 ,@(standard-packages)))
76 (build-inputs `(("emacs" ,emacs)
80 (arguments (strip-keyword-arguments private-keywords arguments)))))
82 (define* (emacs-build store name inputs
86 (configure-flags ''())
87 (phases '(@ (guix build emacs-build-system)
91 (system (%current-system))
93 (imported-modules %emacs-build-system-modules)
94 (modules '((guix build emacs-build-system)
96 (guix build emacs-utils))))
97 "Build SOURCE using EMACS, and with INPUTS."
100 (use-modules ,@modules)
101 (emacs-build #:name ,name
102 #:source ,(match (assoc-ref inputs "source")
103 (((? derivation? source))
104 (derivation->output-path source))
109 #:configure-flags ,configure-flags
111 #:test-target ,test-target
115 #:search-paths ',(map search-path-specification->sexp
117 #:inputs %build-inputs)))
119 (define guile-for-build
122 (package-derivation store guile system #:graft? #f))
124 (let* ((distro (resolve-interface '(gnu packages commencement)))
125 (guile (module-ref distro 'guile-final)))
126 (package-derivation store guile system #:graft? #f)))))
128 (build-expression->derivation store name builder
131 #:modules imported-modules
133 #:guile-for-build guile-for-build))
135 (define emacs-build-system
138 (description "The build system for Emacs packages")
141 ;;; emacs.scm ends here