1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
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 clojure)
20 #:use-module (guix build clojure-utils)
21 #:use-module (guix build-system)
22 #:use-module (guix build-system ant)
23 #:use-module ((guix build-system gnu)
24 #:select (standard-packages)
27 #:use-module (guix derivations)
28 #:use-module (guix packages)
29 #:use-module ((guix search-paths)
31 ((search-path-specification->sexp . search-path-spec->sexp)))
32 #:use-module (guix utils)
34 #:use-module (ice-9 match)
35 #:export (%clojure-build-system-modules
37 clojure-build-system))
41 ;; Standard build procedure for Clojure packages.
45 (define-with-docs %clojure-build-system-modules
46 "Build-side modules imported and used by default."
47 `((guix build clojure-build-system)
48 (guix build clojure-utils)
49 (guix build guile-build-system)
50 ,@%ant-build-system-modules))
52 (define-with-docs %default-clojure
53 "The default Clojure package."
54 (delay (@* (gnu packages clojure) clojure)))
56 (define-with-docs %default-jdk
57 "The default JDK package."
58 (delay (@* (gnu packages java) icedtea)))
60 (define-with-docs %default-zip
61 "The default ZIP package."
62 (delay (@* (gnu packages compression) zip)))
68 (clojure (force %default-clojure))
69 (jdk (force %default-jdk))
70 (zip (force %default-zip))
74 "Return a bag for NAME."
75 (let ((private-keywords '(#:source #:target
76 #:inputs #:native-inputs
77 #:clojure #:jdk #:zip)))
80 (error "No cross-compilation for clojure-build-system yet: LOWER"
84 (host-inputs `(,@(if source
88 ,@(gnu:standard-packages)))
89 (build-inputs `(("clojure" ,clojure)
95 (arguments (strip-keyword-arguments private-keywords
98 (define-with-docs source->output-path
99 "Convert source input to output path."
101 (((? derivation? source))
102 (derivation->output-path source))
108 (define-with-docs maybe-guile->guile
109 "Find the right guile."
111 ((and maybe-guile (? package?))
114 (@* (gnu packages commencement) guile-final))))
116 (define* (clojure-build store name inputs
118 (source-dirs `',%source-dirs)
119 (test-dirs `',%test-dirs)
120 (compile-dir %compile-dir)
122 (jar-names `',(package-name->jar-names name))
123 (main-class %main-class)
124 (omit-source? %omit-source?)
126 (aot-include `',%aot-include)
127 (aot-exclude `',%aot-exclude)
129 doc-dirs ; no sensible default
130 (doc-regex %doc-regex)
133 (test-include `',%test-include)
134 (test-exclude `',%test-exclude)
136 (phases '(@ (guix build clojure-build-system)
140 (system (%current-system))
143 (imported-modules %clojure-build-system-modules)
144 (modules %clojure-build-system-modules))
145 "Build SOURCE with INPUTS."
146 (let ((builder `(begin
147 (use-modules ,@modules)
148 (clojure-build #:name ,name
149 #:source ,(source->output-path
150 (assoc-ref inputs "source"))
152 #:source-dirs ,source-dirs
153 #:test-dirs ,test-dirs
154 #:compile-dir ,compile-dir
156 #:jar-names ,jar-names
157 #:main-class ,main-class
158 #:omit-source? ,omit-source?
160 #:aot-include ,aot-include
161 #:aot-exclude ,aot-exclude
164 #:doc-regex ,doc-regex
167 #:test-include ,test-include
168 #:test-exclude ,test-exclude
172 #:search-paths ',(map search-path-spec->sexp
175 #:inputs %build-inputs)))
177 (guile-for-build (package-derivation store
178 (maybe-guile->guile guile)
182 (build-expression->derivation store name builder
185 #:modules imported-modules
187 #:guile-for-build guile-for-build)))
189 (define clojure-build-system
192 (description "Simple Clojure build system using plain old 'compile'")
195 ;;; clojure.scm ends here