texlive.scm 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
  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 texlive)
  19. #:use-module (guix store)
  20. #:use-module (guix utils)
  21. #:use-module (guix packages)
  22. #:use-module (guix derivations)
  23. #:use-module (guix search-paths)
  24. #:use-module (guix build-system)
  25. #:use-module (guix build-system gnu)
  26. #:use-module (guix svn-download)
  27. #:use-module (ice-9 match)
  28. #:export (%texlive-build-system-modules
  29. texlive-build
  30. texlive-build-system
  31. texlive-ref
  32. texlive-origin
  33. %texlive-tag
  34. %texlive-revision))
  35. ;; Commentary:
  36. ;;
  37. ;; Standard build procedure for Texlive packages.
  38. ;;
  39. ;; Code:
  40. ;; These variables specify the SVN tag and the matching SVN revision. They
  41. ;; are taken from https://www.tug.org/svn/texlive/tags/
  42. (define %texlive-tag "texlive-2018.2")
  43. (define %texlive-revision 49435)
  44. (define (texlive-origin name version locations hash)
  45. "Return an <origin> object for a TeX Live package consisting of multiple
  46. LOCATIONS with a provided HASH. Use NAME and VERSION to compute a prettier
  47. name for the checkout directory."
  48. (origin
  49. (method svn-multi-fetch)
  50. (uri (svn-multi-reference
  51. (url (string-append "svn://www.tug.org/texlive/tags/"
  52. %texlive-tag "/Master/texmf-dist/"))
  53. (locations locations)
  54. (revision %texlive-revision)))
  55. (file-name (string-append name "-" version "-checkout"))
  56. (sha256 hash)))
  57. (define (texlive-ref component id)
  58. "Return a <svn-reference> object for the package ID, which is part of the
  59. given Texlive COMPONENT."
  60. (svn-reference
  61. (url (string-append "svn://www.tug.org/texlive/tags/"
  62. %texlive-tag "/Master/texmf-dist/"
  63. "source/" component "/" id))
  64. (revision %texlive-revision)))
  65. (define %texlive-build-system-modules
  66. ;; Build-side modules imported by default.
  67. `((guix build texlive-build-system)
  68. (guix build union)
  69. ,@%gnu-build-system-modules))
  70. (define (default-texlive-bin)
  71. "Return the default texlive-bin package."
  72. ;; Lazily resolve the binding to avoid a circular dependency.
  73. (let ((tex-mod (resolve-interface '(gnu packages tex))))
  74. (module-ref tex-mod 'texlive-bin)))
  75. (define (default-texlive-latex-base)
  76. "Return the default texlive-latex-base package."
  77. ;; Lazily resolve the binding to avoid a circular dependency.
  78. (let ((tex-mod (resolve-interface '(gnu packages tex))))
  79. (module-ref tex-mod 'texlive-latex-base)))
  80. (define* (lower name
  81. #:key
  82. source inputs native-inputs outputs
  83. system target
  84. (texlive-latex-base (default-texlive-latex-base))
  85. (texlive-bin (default-texlive-bin))
  86. #:allow-other-keys
  87. #:rest arguments)
  88. "Return a bag for NAME."
  89. (define private-keywords
  90. '(#:source #:target #:inputs #:native-inputs
  91. #:texlive-latex-base #:texlive-bin))
  92. (bag
  93. (name name)
  94. (system system)
  95. (host-inputs `(,@(if source
  96. `(("source" ,source))
  97. '())
  98. ,@inputs
  99. ;; Keep the standard inputs of 'gnu-build-system'.
  100. ,@(standard-packages)))
  101. (build-inputs `(("texlive-bin" ,texlive-bin)
  102. ("texlive-latex-base" ,texlive-latex-base)
  103. ,@native-inputs))
  104. (outputs outputs)
  105. (build texlive-build)
  106. (arguments (strip-keyword-arguments private-keywords arguments))))
  107. (define* (texlive-build store name inputs
  108. #:key
  109. (tests? #f)
  110. tex-directory
  111. (build-targets #f)
  112. (tex-format "luatex")
  113. (phases '(@ (guix build texlive-build-system)
  114. %standard-phases))
  115. (outputs '("out"))
  116. (search-paths '())
  117. (system (%current-system))
  118. (guile #f)
  119. (substitutable? #t)
  120. (imported-modules %texlive-build-system-modules)
  121. (modules '((guix build texlive-build-system)
  122. (guix build union)
  123. (guix build utils))))
  124. "Build SOURCE with INPUTS."
  125. (define builder
  126. `(begin
  127. (use-modules ,@modules)
  128. (texlive-build #:name ,name
  129. #:source ,(match (assoc-ref inputs "source")
  130. (((? derivation? source))
  131. (derivation->output-path source))
  132. ((source)
  133. source)
  134. (source
  135. source))
  136. #:tex-directory ,tex-directory
  137. #:build-targets ,build-targets
  138. #:tex-format ,tex-format
  139. #:system ,system
  140. #:tests? ,tests?
  141. #:phases ,phases
  142. #:outputs %outputs
  143. #:search-paths ',(map search-path-specification->sexp
  144. search-paths)
  145. #:inputs %build-inputs)))
  146. (define guile-for-build
  147. (match guile
  148. ((? package?)
  149. (package-derivation store guile system #:graft? #f))
  150. (#f ; the default
  151. (let* ((distro (resolve-interface '(gnu packages commencement)))
  152. (guile (module-ref distro 'guile-final)))
  153. (package-derivation store guile system #:graft? #f)))))
  154. (build-expression->derivation store name builder
  155. #:inputs inputs
  156. #:system system
  157. #:modules imported-modules
  158. #:outputs outputs
  159. #:guile-for-build guile-for-build
  160. #:substitutable? substitutable?))
  161. (define texlive-build-system
  162. (build-system
  163. (name 'texlive)
  164. (description "The build system for TeX Live packages")
  165. (lower lower)))
  166. ;;; texlive.scm ends here