texlive.scm 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2021-2022 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2021 Thiago Jung Bauermann <bauermann@kolabnow.com>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. (define-module (guix build-system texlive)
  21. #:use-module (guix store)
  22. #:use-module (guix utils)
  23. #:use-module (guix packages)
  24. #:use-module (guix monads)
  25. #:use-module (guix gexp)
  26. #:use-module (guix search-paths)
  27. #:use-module (guix build-system)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (guix svn-download)
  30. #:export (%texlive-build-system-modules
  31. texlive-build
  32. texlive-build-system
  33. texlive-ref
  34. texlive-origin
  35. %texlive-tag
  36. %texlive-revision))
  37. ;; Commentary:
  38. ;;
  39. ;; Standard build procedure for Texlive packages.
  40. ;;
  41. ;; Code:
  42. ;; These variables specify the SVN tag and the matching SVN revision. They
  43. ;; are taken from https://www.tug.org/svn/texlive/tags/
  44. (define %texlive-tag "texlive-2021.3")
  45. (define %texlive-revision 59745)
  46. (define (texlive-origin name version locations hash)
  47. "Return an <origin> object for a TeX Live package consisting of multiple
  48. LOCATIONS with a provided HASH. Use NAME and VERSION to compute a prettier
  49. name for the checkout directory."
  50. (origin
  51. (method svn-multi-fetch)
  52. (uri (svn-multi-reference
  53. (url (string-append "svn://www.tug.org/texlive/tags/"
  54. %texlive-tag "/Master/texmf-dist/"))
  55. (locations locations)
  56. (revision %texlive-revision)))
  57. (file-name (string-append name "-" version "-checkout"))
  58. (sha256 hash)))
  59. (define* (texlive-ref component #:optional id)
  60. "Return a <svn-reference> object for the package ID, which is part of the
  61. given Texlive COMPONENT. If ID is not provided, COMPONENT is used as the top
  62. level package ID."
  63. (svn-reference
  64. (url (string-append "svn://www.tug.org/texlive/tags/"
  65. %texlive-tag "/Master/texmf-dist/"
  66. "source/" component
  67. (if id
  68. (string-append "/" id)
  69. "")))
  70. (revision %texlive-revision)))
  71. (define %texlive-build-system-modules
  72. ;; Build-side modules imported by default.
  73. `((guix build texlive-build-system)
  74. (guix build union)
  75. ,@%gnu-build-system-modules))
  76. (define (default-texlive-bin)
  77. "Return the default texlive-bin package."
  78. ;; Lazily resolve the binding to avoid a circular dependency.
  79. (let ((tex-mod (resolve-interface '(gnu packages tex))))
  80. (module-ref tex-mod 'texlive-bin)))
  81. (define (default-texlive-latex-base)
  82. "Return the default texlive-latex-base package."
  83. ;; Lazily resolve the binding to avoid a circular dependency.
  84. (let ((tex-mod (resolve-interface '(gnu packages tex))))
  85. (module-ref tex-mod 'texlive-latex-base)))
  86. (define* (lower name
  87. #:key
  88. source inputs native-inputs outputs
  89. system target
  90. (texlive-latex-base (default-texlive-latex-base))
  91. (texlive-bin (default-texlive-bin))
  92. #:allow-other-keys
  93. #:rest arguments)
  94. "Return a bag for NAME."
  95. (define private-keywords
  96. '(#:target #:inputs #:native-inputs
  97. #:texlive-latex-base #:texlive-bin))
  98. (bag
  99. (name name)
  100. (system system)
  101. (host-inputs `(,@(if source
  102. `(("source" ,source))
  103. '())
  104. ,@inputs
  105. ;; Keep the standard inputs of 'gnu-build-system'.
  106. ,@(standard-packages)))
  107. (build-inputs `(("texlive-bin" ,texlive-bin)
  108. ,@(if texlive-latex-base
  109. `(("texlive-latex-base" ,texlive-latex-base))
  110. '())
  111. ,@native-inputs))
  112. (outputs outputs)
  113. (build texlive-build)
  114. (arguments (strip-keyword-arguments private-keywords arguments))))
  115. (define* (texlive-build name inputs
  116. #:key
  117. source
  118. (tests? #f)
  119. tex-directory
  120. (build-targets #f)
  121. (tex-engine #f)
  122. ;; FIXME: This would normally default to "luatex" but
  123. ;; LuaTeX has a bug where sometimes it corrupts the
  124. ;; heap and aborts. This causes the build of texlive
  125. ;; packages to fail at random. The problem is being
  126. ;; tracked at <https://issues.guix.gnu.org/48064>.
  127. (tex-format "pdftex")
  128. (phases '(@ (guix build texlive-build-system)
  129. %standard-phases))
  130. (outputs '("out"))
  131. (search-paths '())
  132. (system (%current-system))
  133. (guile #f)
  134. (substitutable? #t)
  135. (imported-modules %texlive-build-system-modules)
  136. (modules '((guix build texlive-build-system)
  137. (guix build union)
  138. (guix build utils))))
  139. "Build SOURCE with INPUTS."
  140. (define builder
  141. (with-imported-modules imported-modules
  142. #~(begin
  143. (use-modules #$@(sexp->gexp modules))
  144. #$(with-build-variables inputs outputs
  145. #~(texlive-build #:name #$name
  146. #:source #+source
  147. #:tex-directory #$tex-directory
  148. #:build-targets #$build-targets
  149. #:tex-engine #$(if tex-engine
  150. tex-engine
  151. tex-format)
  152. #:tex-format #$tex-format
  153. #:system #$system
  154. #:tests? #$tests?
  155. #:phases #$(if (pair? phases)
  156. (sexp->gexp phases)
  157. phases)
  158. #:outputs %outputs
  159. #:inputs %build-inputs
  160. #:search-paths '#$(sexp->gexp
  161. (map search-path-specification->sexp
  162. search-paths)))))))
  163. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  164. system #:graft? #f)))
  165. (gexp->derivation name builder
  166. #:system system
  167. #:target #f
  168. #:graft? #f
  169. #:substitutable? substitutable?
  170. #:guile-for-build guile)))
  171. (define texlive-build-system
  172. (build-system
  173. (name 'texlive)
  174. (description "The build system for TeX Live packages")
  175. (lower lower)))
  176. ;;; texlive.scm ends here