texlive.scm 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  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.
  11. ;;;
  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.
  16. ;;;
  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/>.
  19. (define-module (guix build-system texlive)
  20. #:use-module (guix store)
  21. #:use-module (guix utils)
  22. #:use-module (guix packages)
  23. #:use-module (guix monads)
  24. #:use-module (guix gexp)
  25. #:use-module (guix search-paths)
  26. #:use-module (guix build-system)
  27. #:use-module (guix build-system gnu)
  28. #:use-module (guix svn-download)
  29. #:use-module (ice-9 match)
  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-2020.0")
  45. (define %texlive-revision 54632)
  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. ("texlive-latex-base" ,texlive-latex-base)
  109. ,@native-inputs))
  110. (outputs outputs)
  111. (build texlive-build)
  112. (arguments (strip-keyword-arguments private-keywords arguments))))
  113. (define* (texlive-build name inputs
  114. #:key
  115. source
  116. (tests? #f)
  117. tex-directory
  118. (build-targets #f)
  119. (tex-format "luatex")
  120. (phases '(@ (guix build texlive-build-system)
  121. %standard-phases))
  122. (outputs '("out"))
  123. (search-paths '())
  124. (system (%current-system))
  125. (guile #f)
  126. (substitutable? #t)
  127. (imported-modules %texlive-build-system-modules)
  128. (modules '((guix build texlive-build-system)
  129. (guix build union)
  130. (guix build utils))))
  131. "Build SOURCE with INPUTS."
  132. (define builder
  133. (with-imported-modules imported-modules
  134. #~(begin
  135. (use-modules #$@(sexp->gexp modules))
  136. #$(with-build-variables inputs outputs
  137. #~(texlive-build #:name #$name
  138. #:source #+source
  139. #:tex-directory #$tex-directory
  140. #:build-targets #$build-targets
  141. #:tex-format #$tex-format
  142. #:system #$system
  143. #:tests? #$tests?
  144. #:phases #$(if (pair? phases)
  145. (sexp->gexp phases)
  146. phases)
  147. #:outputs %outputs
  148. #:inputs %build-inputs
  149. #:search-paths '#$(sexp->gexp
  150. (map search-path-specification->sexp
  151. search-paths)))))))
  152. (gexp->derivation name builder
  153. #:system system
  154. #:target #f
  155. #:substitutable? substitutable?))
  156. (define texlive-build-system
  157. (build-system
  158. (name 'texlive)
  159. (description "The build system for TeX Live packages")
  160. (lower lower)))
  161. ;;; texlive.scm ends here