1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2014, 2015 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 ruby)
21 #:use-module (guix store)
22 #:use-module (guix utils)
23 #:use-module (guix packages)
24 #:use-module (guix derivations)
25 #:use-module (guix search-paths)
26 #:use-module (guix build-system)
27 #:use-module (guix build-system gnu)
28 #:use-module (ice-9 match)
29 #:export (%ruby-build-system-modules
33 (define %ruby-build-system-modules
34 ;; Build-side modules imported by default.
35 `((guix build ruby-build-system)
36 ,@%gnu-build-system-modules))
38 (define (default-ruby)
39 "Return the default Ruby package."
40 ;; Lazily resolve the binding to avoid a circular dependency.
41 (let ((ruby (resolve-interface '(gnu packages ruby))))
42 (module-ref ruby 'ruby)))
45 #:key source inputs native-inputs outputs system target
49 "Return a bag for NAME."
50 (define private-keywords
51 '(#:source #:target #:ruby #:inputs #:native-inputs))
53 (let ((version-control (resolve-interface '(gnu packages version-control))))
54 (and (not target) ;XXX: no cross-compilation
58 (host-inputs `(,@(if source
63 ;; Keep the standard inputs of 'gnu-build-system'.
64 ,@(standard-packages)))
65 (build-inputs `(("ruby" ,ruby)
66 ("git" ,(module-ref version-control 'git))
70 (arguments (strip-keyword-arguments private-keywords arguments))))))
72 (define* (ruby-build store name inputs
77 (phases '(@ (guix build ruby-build-system)
81 (system (%current-system))
83 (imported-modules %ruby-build-system-modules)
84 (modules '((guix build ruby-build-system)
86 "Build SOURCE using RUBY and INPUTS."
89 (use-modules ,@modules)
90 (ruby-build #:name ,name
91 #:source ,(match (assoc-ref inputs "source")
92 (((? derivation? source))
93 (derivation->output-path source))
99 #:gem-flags ,gem-flags
100 #:test-target ,test-target
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 ruby-build-system
127 (description "The standard Ruby build system")