1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Nicolò Balzarotti <nicolo@nixo.xyz>
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 julia)
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 (%julia-build-system-modules
35 ;; Standard build procedure for Julia packages.
39 (define %julia-build-system-modules
40 ;; Build-side modules imported by default.
41 `((guix build julia-build-system)
42 ,@%gnu-build-system-modules))
44 (define (default-julia)
45 "Return the default Julia package."
46 ;; Lazily resolve the binding to avoid a circular dependency.
47 (let ((julia-mod (resolve-interface '(gnu packages julia))))
48 (module-ref julia-mod 'julia)))
51 #:key source inputs native-inputs outputs system target
52 (julia (default-julia))
55 "Return a bag for NAME."
56 (define private-keywords
57 '(#:target #:julia #:inputs #:native-inputs))
59 (and (not target) ;XXX: no cross-compilation
63 (host-inputs `(,@(if source
68 ;; Keep the standard inputs of 'gnu-build-system'.
69 ,@(standard-packages)))
70 (build-inputs `(("julia" ,julia)
74 (arguments (strip-keyword-arguments private-keywords arguments)))))
76 (define* (julia-build store name inputs
79 (phases '(@ (guix build julia-build-system)
83 (system (%current-system))
85 (imported-modules %julia-build-system-modules)
86 (modules '((guix build julia-build-system)
88 "Build SOURCE using Julia, and with INPUTS."
91 (use-modules ,@modules)
92 (julia-build #:name ,name
93 #:source ,(match (assoc-ref inputs "source")
94 (((? derivation? source))
95 (derivation->output-path source))
104 #:search-paths ',(map search-path-specification->sexp
106 #:inputs %build-inputs)))
108 (define guile-for-build
111 (package-derivation store guile system #:graft? #f))
113 (let* ((distro (resolve-interface '(gnu packages commencement)))
114 (guile (module-ref distro 'guile-final)))
115 (package-derivation store guile system #:graft? #f)))))
117 (build-expression->derivation store name builder
120 #:modules imported-modules
122 #:guile-for-build guile-for-build))
124 (define julia-build-system
127 (description "The build system for Julia packages")
130 ;;; julia.scm ends here