1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
3 ;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
20 (define-module (guix build-system clojure)
21 #:use-module (guix build clojure-utils)
22 #:use-module (guix build-system)
23 #:use-module (guix build-system ant)
24 #:use-module ((guix build-system gnu)
25 #:select (standard-packages)
28 #:use-module (guix derivations)
29 #:use-module (guix packages)
30 #:use-module ((guix search-paths)
32 ((search-path-specification->sexp . search-path-spec->sexp)))
33 #:use-module (guix utils)
35 #:use-module (ice-9 match)
36 #:export (%clojure-build-system-modules
38 clojure-build-system))
42 ;; Standard build procedure for Clojure packages.
46 (define-with-docs %clojure-build-system-modules
47 "Build-side modules imported by default."
48 `((guix build clojure-build-system)
49 (guix build clojure-utils)
50 (guix build guile-build-system)
51 ,@%ant-build-system-modules))
53 (define %default-modules
54 ;; Modules in scope in the build-side environment.
55 '((guix build clojure-build-system)
56 (guix build clojure-utils)
59 (define-with-docs %default-clojure
60 "The default Clojure package."
61 (delay (@* (gnu packages clojure) clojure)))
63 (define-with-docs %default-jdk
64 "The default JDK package."
65 (delay (@* (gnu packages java) icedtea)))
67 (define-with-docs %default-zip
68 "The default ZIP package."
69 (delay (@* (gnu packages compression) zip)))
75 (clojure (force %default-clojure))
76 (jdk (force %default-jdk))
77 (zip (force %default-zip))
81 "Return a bag for NAME."
82 (let ((private-keywords '(#:source #:target
83 #:inputs #:native-inputs
84 #:clojure #:jdk #:zip)))
87 (error "No cross-compilation for clojure-build-system yet: LOWER"
91 (host-inputs `(,@(if source
95 ,@(gnu:standard-packages)))
96 (build-inputs `(("clojure" ,clojure)
101 (build clojure-build)
102 (arguments (strip-keyword-arguments private-keywords
105 (define-with-docs source->output-path
106 "Convert source input to output path."
108 (((? derivation? source))
109 (derivation->output-path source))
115 (define-with-docs maybe-guile->guile
116 "Find the right guile."
118 ((and maybe-guile (? package?))
121 (@* (gnu packages commencement) guile-final))))
123 (define* (clojure-build store name inputs
125 (source-dirs `',%source-dirs)
126 (test-dirs `',%test-dirs)
127 (compile-dir %compile-dir)
129 (jar-names `',(package-name->jar-names name))
130 (main-class %main-class)
131 (omit-source? %omit-source?)
133 (aot-include `',%aot-include)
134 (aot-exclude `',%aot-exclude)
136 doc-dirs ; no sensible default
137 (doc-regex %doc-regex)
140 (test-include `',%test-include)
141 (test-exclude `',%test-exclude)
143 (phases '%standard-phases)
146 (system (%current-system))
149 (imported-modules %clojure-build-system-modules)
150 (modules %default-modules))
151 "Build SOURCE with INPUTS."
152 (let ((builder `(begin
153 (use-modules ,@modules)
154 (clojure-build #:name ,name
155 #:source ,(source->output-path
156 (assoc-ref inputs "source"))
158 #:source-dirs ,source-dirs
159 #:test-dirs ,test-dirs
160 #:compile-dir ,compile-dir
162 #:jar-names ,jar-names
163 #:main-class ,main-class
164 #:omit-source? ,omit-source?
166 #:aot-include ,aot-include
167 #:aot-exclude ,aot-exclude
170 #:doc-regex ,doc-regex
173 #:test-include ,test-include
174 #:test-exclude ,test-exclude
178 #:search-paths ',(map search-path-spec->sexp
181 #:inputs %build-inputs)))
183 (guile-for-build (package-derivation store
184 (maybe-guile->guile guile)
188 (build-expression->derivation store name builder
191 #:modules imported-modules
193 #:guile-for-build guile-for-build)))
195 (define clojure-build-system
198 (description "Simple Clojure build system using plain old 'compile'")
201 ;;; clojure.scm ends here