Commit | Line | Data |
---|---|---|
e9137a53 FB |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch> | |
d98e0a27 | 3 | ;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com> |
e9137a53 FB |
4 | ;;; |
5 | ;;; This file is part of GNU Guix. | |
6 | ;;; | |
7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
8 | ;;; under the terms of the GNU General Public License as published by | |
9 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
10 | ;;; your option) any later version. | |
11 | ;;; | |
12 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;;; GNU General Public License for more details. | |
16 | ;;; | |
17 | ;;; You should have received a copy of the GNU General Public License | |
18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
20 | (define-module (guix build-system emacs) | |
df34f478 MC |
21 | #:use-module ((guix build emacs-build-system) |
22 | #:select (%default-include %default-exclude)) | |
e9137a53 FB |
23 | #:use-module (guix store) |
24 | #:use-module (guix utils) | |
25 | #:use-module (guix packages) | |
26 | #:use-module (guix derivations) | |
27 | #:use-module (guix search-paths) | |
28 | #:use-module (guix build-system) | |
29 | #:use-module (guix build-system gnu) | |
30 | #:use-module (ice-9 match) | |
31 | #:use-module (srfi srfi-26) | |
32 | #:export (%emacs-build-system-modules | |
33 | emacs-build | |
df34f478 MC |
34 | emacs-build-system) |
35 | #:re-export (%default-include ;for convenience | |
36 | %default-exclude)) | |
37 | ||
e9137a53 FB |
38 | |
39 | ;; Commentary: | |
40 | ;; | |
41 | ;; Standard build procedure for Emacs packages. This is implemented as an | |
42 | ;; extension of 'gnu-build-system'. | |
43 | ;; | |
44 | ;; Code: | |
45 | ||
46 | (define %emacs-build-system-modules | |
47 | ;; Build-side modules imported by default. | |
48 | `((guix build emacs-build-system) | |
49 | (guix build emacs-utils) | |
50 | ,@%gnu-build-system-modules)) | |
51 | ||
52 | (define (default-emacs) | |
53 | "Return the default Emacs package." | |
54 | ;; Lazily resolve the binding to avoid a circular dependency. | |
55 | (let ((emacs-mod (resolve-interface '(gnu packages emacs)))) | |
a6eafbed | 56 | (module-ref emacs-mod 'emacs-minimal))) |
e9137a53 FB |
57 | |
58 | (define* (lower name | |
59 | #:key source inputs native-inputs outputs system target | |
60 | (emacs (default-emacs)) | |
61 | #:allow-other-keys | |
62 | #:rest arguments) | |
63 | "Return a bag for NAME." | |
64 | (define private-keywords | |
65 | '(#:target #:emacs #:inputs #:native-inputs)) | |
66 | ||
67 | (and (not target) ;XXX: no cross-compilation | |
68 | (bag | |
69 | (name name) | |
70 | (system system) | |
71 | (host-inputs `(,@(if source | |
72 | `(("source" ,source)) | |
73 | '()) | |
74 | ,@inputs | |
75 | ||
76 | ;; Keep the standard inputs of 'gnu-build-system'. | |
77 | ,@(standard-packages))) | |
78 | (build-inputs `(("emacs" ,emacs) | |
79 | ,@native-inputs)) | |
80 | (outputs outputs) | |
81 | (build emacs-build) | |
82 | (arguments (strip-keyword-arguments private-keywords arguments))))) | |
83 | ||
84 | (define* (emacs-build store name inputs | |
85 | #:key source | |
58b6812f MC |
86 | (tests? #f) |
87 | (parallel-tests? #t) | |
facc0a96 | 88 | (test-command ''("make" "check")) |
e9137a53 FB |
89 | (phases '(@ (guix build emacs-build-system) |
90 | %standard-phases)) | |
91 | (outputs '("out")) | |
df34f478 MC |
92 | (include (quote %default-include)) |
93 | (exclude (quote %default-exclude)) | |
e9137a53 FB |
94 | (search-paths '()) |
95 | (system (%current-system)) | |
96 | (guile #f) | |
97 | (imported-modules %emacs-build-system-modules) | |
98 | (modules '((guix build emacs-build-system) | |
99 | (guix build utils) | |
100 | (guix build emacs-utils)))) | |
101 | "Build SOURCE using EMACS, and with INPUTS." | |
102 | (define builder | |
103 | `(begin | |
104 | (use-modules ,@modules) | |
105 | (emacs-build #:name ,name | |
106 | #:source ,(match (assoc-ref inputs "source") | |
107 | (((? derivation? source)) | |
108 | (derivation->output-path source)) | |
109 | ((source) | |
110 | source) | |
111 | (source | |
112 | source)) | |
e9137a53 | 113 | #:system ,system |
facc0a96 | 114 | #:test-command ,test-command |
e9137a53 | 115 | #:tests? ,tests? |
d98e0a27 | 116 | #:parallel-tests? ,parallel-tests? |
e9137a53 FB |
117 | #:phases ,phases |
118 | #:outputs %outputs | |
d8796851 AI |
119 | #:include ,include |
120 | #:exclude ,exclude | |
e9137a53 FB |
121 | #:search-paths ',(map search-path-specification->sexp |
122 | search-paths) | |
123 | #:inputs %build-inputs))) | |
124 | ||
125 | (define guile-for-build | |
126 | (match guile | |
127 | ((? package?) | |
128 | (package-derivation store guile system #:graft? #f)) | |
129 | (#f ; the default | |
130 | (let* ((distro (resolve-interface '(gnu packages commencement))) | |
131 | (guile (module-ref distro 'guile-final))) | |
132 | (package-derivation store guile system #:graft? #f))))) | |
133 | ||
134 | (build-expression->derivation store name builder | |
135 | #:inputs inputs | |
136 | #:system system | |
137 | #:modules imported-modules | |
138 | #:outputs outputs | |
139 | #:guile-for-build guile-for-build)) | |
140 | ||
141 | (define emacs-build-system | |
142 | (build-system | |
143 | (name 'emacs) | |
144 | (description "The build system for Emacs packages") | |
145 | (lower lower))) | |
146 | ||
147 | ;;; emacs.scm ends here |