You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
4.3 KiB

  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014 David Thompson <davet@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  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.
  10. ;;;
  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.
  15. ;;;
  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/>.
  18. (define-module (guix build-system ruby)
  19. #:use-module (guix store)
  20. #:use-module (guix utils)
  21. #:use-module (guix packages)
  22. #:use-module (guix derivations)
  23. #:use-module (guix build-system)
  24. #:use-module (guix build-system gnu)
  25. #:use-module (gnu packages version-control)
  26. #:use-module (ice-9 match)
  27. #:use-module (srfi srfi-26)
  28. #:export (ruby-build
  29. ruby-build-system))
  30. (define (default-ruby)
  31. "Return the default Ruby package."
  32. ;; Lazily resolve the binding to avoid a circular dependency.
  33. (let ((ruby (resolve-interface '(gnu packages ruby))))
  34. (module-ref ruby 'ruby)))
  35. (define* (ruby-build store name source inputs
  36. #:key
  37. (ruby (default-ruby))
  38. (test-target "test")
  39. (tests? #t)
  40. (phases '(@ (guix build ruby-build-system)
  41. %standard-phases))
  42. (outputs '("out"))
  43. (search-paths '())
  44. (system (%current-system))
  45. (guile #f)
  46. (imported-modules '((guix build ruby-build-system)
  47. (guix build gnu-build-system)
  48. (guix build utils)))
  49. (modules '((guix build ruby-build-system)
  50. (guix build utils))))
  51. "Build SOURCE using RUBY and INPUTS."
  52. (define ruby-search-paths
  53. (append (package-native-search-paths ruby)
  54. (standard-search-paths)))
  55. (define builder
  56. `(begin
  57. (use-modules ,@modules)
  58. (ruby-build #:name ,name
  59. #:source ,(if (derivation? source)
  60. (derivation->output-path source)
  61. source)
  62. #:system ,system
  63. #:test-target ,test-target
  64. #:tests? ,tests?
  65. #:phases ,phases
  66. #:outputs %outputs
  67. #:search-paths ',(map search-path-specification->sexp
  68. (append ruby-search-paths
  69. search-paths))
  70. #:inputs %build-inputs)))
  71. (define guile-for-build
  72. (match guile
  73. ((? package?)
  74. (package-derivation store guile system))
  75. ((and (? string?) (? derivation-path?))
  76. guile)
  77. (#f
  78. (let* ((distro (resolve-interface '(gnu packages commencement)))
  79. (guile (module-ref distro 'guile-final)))
  80. (package-derivation store guile system)))))
  81. (let ((ruby (package-derivation store ruby system))
  82. (git (package-derivation store git system)))
  83. (build-expression->derivation store name builder
  84. #:inputs
  85. `(,@(if source
  86. `(("source" ,source))
  87. '())
  88. ("ruby" ,ruby)
  89. ,@inputs
  90. ;; Keep the standard inputs of
  91. ;; 'gnu-build-system'.
  92. ,@(standard-inputs system))
  93. #:system system
  94. #:modules imported-modules
  95. #:outputs outputs
  96. #:guile-for-build guile-for-build)))
  97. (define ruby-build-system
  98. (build-system
  99. (name 'ruby)
  100. (description "The standard Ruby build system")
  101. (build ruby-build)))