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
76 (phases '(@ (guix build ruby-build-system)
80 (system (%current-system))
82 (imported-modules %ruby-build-system-modules)
83 (modules '((guix build ruby-build-system)
85 "Build SOURCE using RUBY and INPUTS."
88 (use-modules ,@modules)
89 (ruby-build #:name ,name
90 #:source ,(match (assoc-ref inputs "source")
91 (((? derivation? source))
92 (derivation->output-path source))
98 #:test-target ,test-target
102 #:search-paths ',(map search-path-specification->sexp
104 #:inputs %build-inputs)))
106 (define guile-for-build
109 (package-derivation store guile system #:graft? #f))
111 (let* ((distro (resolve-interface '(gnu packages commencement)))
112 (guile (module-ref distro 'guile-final)))
113 (package-derivation store guile system #:graft? #f)))))
115 (build-expression->derivation store name builder
118 #:modules imported-modules
120 #:guile-for-build guile-for-build))
122 (define ruby-build-system
125 (description "The standard Ruby build system")