tex.scm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. (define-module (staging tex)
  2. #:use-module ((guix licenses) #:prefix license:)
  3. #:use-module (guix packages)
  4. #:use-module (guix git-download)
  5. #:use-module (guix svn-download)
  6. #:use-module (guix utils)
  7. #:use-module (guix build-system texlive)
  8. #:use-module (guix build-system trivial)
  9. #:use-module (gnu packages tex))
  10. (define* (simple-texlive-package name locations hash
  11. #:key trivial?)
  12. "Return a template for a simple TeX Live package with the given NAME,
  13. downloading from a list of LOCATIONS in the TeX Live repository, and
  14. expecting the provided output HASH. If TRIVIAL? is provided, all
  15. files will simply be copied to their outputs; otherwise the
  16. TEXLIVE-BUILD-SYSTEM is used."
  17. (define with-documentation?
  18. (and trivial?
  19. (any (lambda (location)
  20. (string-prefix? "/doc" location))
  21. locations)))
  22. (package
  23. (name name)
  24. (version (number->string %texlive-revision))
  25. (source (texlive-origin name version
  26. locations hash))
  27. (outputs (if with-documentation?
  28. '("out" "doc")
  29. '("out")))
  30. (build-system (if trivial?
  31. gnu-build-system
  32. texlive-build-system))
  33. (arguments
  34. (let ((copy-files
  35. `(lambda* (#:key outputs inputs #:allow-other-keys)
  36. (let (,@(if with-documentation?
  37. `((doc (string-append (assoc-ref outputs "doc")
  38. "/share/texmf-dist/")))
  39. '())
  40. (out (string-append (assoc-ref outputs "out")
  41. "/share/texmf-dist/")))
  42. ,@(if with-documentation?
  43. '((mkdir-p doc)
  44. (copy-recursively
  45. (string-append (assoc-ref inputs "source") "/doc")
  46. (string-append doc "/doc")))
  47. '())
  48. (mkdir-p out)
  49. (copy-recursively (assoc-ref inputs "source") out)
  50. ,@(if with-documentation?
  51. '((delete-file-recursively (string-append out "/doc")))
  52. '())
  53. #t))))
  54. (if trivial?
  55. `(#:tests? #f
  56. #:phases
  57. (modify-phases %standard-phases
  58. (delete 'configure)
  59. (replace 'build (const #t))
  60. (replace 'install ,copy-files)))
  61. `(#:phases
  62. (modify-phases %standard-phases
  63. (add-after 'install 'copy-files ,copy-files))))))
  64. (home-page #f)
  65. (synopsis #f)
  66. (description #f)
  67. (license #f)))
  68. (define-public texlive-amsfonts-patched
  69. (let ((template (simple-texlive-package
  70. "texlive-amsfonts"
  71. (list "/source/latex/amsfonts/"
  72. "/fonts/source/public/amsfonts/"
  73. "/fonts/type1/public/amsfonts/"
  74. "/fonts/afm/public/amsfonts/"
  75. "/fonts/map/dvips/amsfonts/"
  76. "/tex/plain/amsfonts/"
  77. "/doc/fonts/amsfonts/")
  78. (base32
  79. "15q70nkjf8wqzbd5ivcdx3i2sdgqxjb38q0qn9a2qw9i0qcnx6zw"))))
  80. (package
  81. (inherit template)
  82. (arguments
  83. (substitute-keyword-arguments (package-arguments template)
  84. ((#:build-targets _ #t)
  85. '(list "amsfonts.ins"))
  86. ((#:tex-directory _ #t)
  87. "latex/amsfonts")
  88. ((#:modules modules '())
  89. `((guix build texlive-build-system)
  90. (guix build utils)
  91. (ice-9 match)
  92. (srfi srfi-1)
  93. (srfi srfi-26)))
  94. ((#:phases phases)
  95. `(modify-phases ,phases
  96. (add-before 'build 'build-fonts
  97. (lambda* (#:key inputs #:allow-other-keys)
  98. (let ((mf (assoc-ref inputs "texlive-union"))
  99. (src (string-append (getcwd) "/fonts/source/public/amsfonts/")))
  100. ;; Make METAFONT reproducible
  101. (setenv "SOURCE_DATE_EPOCH" "1")
  102. ;; Tell mf where to find mf.base
  103. (setenv "MFBASES" (string-append mf "/share/texmf-dist/web2c"))
  104. ;; Tell mf where to look for source files
  105. (setenv "MFINPUTS"
  106. (string-append src ":"
  107. src "/cmextra:"
  108. src "/cyrillic:"
  109. src "/dummy:"
  110. src "/symbols:"
  111. mf "/share/texmf-dist/metafont/base:"
  112. (assoc-ref inputs "texlive-cm")
  113. "/share/texmf-dist/fonts/source/public/cm")))
  114. (let ((build (string-append (getcwd) "/build-fonts")))
  115. (mkdir-p build)
  116. (with-directory-excursion "fonts/source/public/amsfonts"
  117. (for-each (lambda (font)
  118. (format #t "building font ~a\n" (basename font ".mf"))
  119. (with-directory-excursion (dirname font)
  120. (invoke "mf" "-progname=mf"
  121. (string-append "-output-directory=" build)
  122. (string-append "\\"
  123. "mode:=ljfour; "
  124. "mag:=1; "
  125. "nonstopmode; "
  126. "input "
  127. (getcwd) "/"
  128. (basename font ".mf")))))
  129. (find-files "." "[0-9]+\\.mf$"))))
  130. ;; There are no metafont sources for the Euler fonts, so we
  131. ;; convert the afm files instead.
  132. (let ((build (string-append (getcwd) "/build-fonts/euler")))
  133. (mkdir build)
  134. (with-directory-excursion "fonts/afm/public/amsfonts/euler/"
  135. (for-each (lambda (font)
  136. (format #t "converting afm font ~a\n" (basename font ".afm"))
  137. (invoke "afm2tfm" font
  138. (string-append build "/"
  139. (basename font ".tfm"))))
  140. (find-files "." "\\.afm$")))
  141. ;; Frustratingly, not all fonts can be created this way. To
  142. ;; generate eufm8.tfm, for example, we first scale down
  143. ;; eufm10.afm to eufm8.pl, and then generate the tfm file from
  144. ;; the pl file.
  145. (setenv "TEXINPUTS"
  146. (string-append build "//:"
  147. (getcwd) "/fonts/afm/public/amsfonts//:"
  148. (getcwd) "/source/latex/amsfonts//:"
  149. (assoc-ref inputs "texlive-union") "//"))
  150. (with-directory-excursion build
  151. (for-each (match-lambda
  152. (((target-base target-size)
  153. (source-base source-size))
  154. (let ((factor (number->string
  155. (truncate/ (* 1000 target-size)
  156. source-size))))
  157. (invoke "tex"
  158. "-interaction=scrollmode"
  159. (string-append "\\input fontinst.sty "
  160. "\\transformfont{" target-base "}"
  161. "{\\scalefont{" factor "}"
  162. "{\\fromafm{" source-base "}}} "
  163. "\\bye")))
  164. (invoke "pltotf"
  165. (string-append target-base ".pl")
  166. (string-append target-base ".tfm"))
  167. (delete-file (string-append target-base ".pl"))))
  168. '((("eufm8" 8) ("eufm10" 10))
  169. (("eufb6" 6) ("eufb7" 7))
  170. (("eufb8" 8) ("eufb10" 10))
  171. (("eufb9" 9) ("eufb10" 10))
  172. (("eufm6" 6) ("eufb7" 7))
  173. (("eufm9" 9) ("eufb10" 10))
  174. (("eurb6" 6) ("eurb7" 7))
  175. (("eurb8" 8) ("eurb10" 10))
  176. (("eurb9" 9) ("eurb10" 10))
  177. (("eurm6" 6) ("eurm7" 7))
  178. (("eurm8" 8) ("eurm10" 10))
  179. (("eurm9" 9) ("eurm10" 10))))))
  180. #t))
  181. (add-after 'install 'install-generated-fonts
  182. (lambda* (#:key inputs outputs #:allow-other-keys)
  183. (copy-recursively "build-fonts"
  184. (string-append
  185. (assoc-ref outputs "out")
  186. "/share/texmf-dist/fonts/tfm/public/amsfonts"))
  187. #t))))))
  188. (native-inputs
  189. `(("texlive-union" ,(texlive-union (list texlive-tex-fontinst-base
  190. texlive-cm
  191. texlive-metafont-base)))))
  192. (home-page "https://www.ctan.org/pkg/amsfonts")
  193. (synopsis "TeX fonts from the American Mathematical Society")
  194. (description
  195. "This package provides an extended set of fonts for use in mathematics,
  196. including: extra mathematical symbols; blackboard bold letters (uppercase
  197. only); fraktur letters; subscript sizes of bold math italic and bold Greek
  198. letters; subscript sizes of large symbols such as sum and product; added sizes
  199. of the Computer Modern small caps font; cyrillic fonts (from the University of
  200. Washington); Euler mathematical fonts. All fonts are provided as Adobe Type 1
  201. files, and all except the Euler fonts are provided as Metafont source. The
  202. distribution also includes the canonical Type 1 versions of the Computer
  203. Modern family of fonts. The Euler fonts are supported by separate packages;
  204. details can be found in the documentation.")
  205. (license license:silofl1.1))))
  206. (define-public texlive-logreq
  207. (package
  208. (name "texlive-logreq")
  209. (version (number->string %texlive-revision))
  210. (source
  211. (origin
  212. (method svn-fetch)
  213. (uri (svn-reference
  214. (url (string-append "svn://www.tug.org/texlive/tags/"
  215. %texlive-tag "/Master/texmf-dist/"
  216. "/tex/latex/logreq"))
  217. (revision %texlive-revision)))
  218. (file-name (string-append name "-" version "-checkout"))
  219. (sha256
  220. (base32
  221. "016l3p0f315cwq2ylpd2a7dwlxb42xxcd2al5j1wpg8g8scwbfq5"))))
  222. (build-system trivial-build-system)
  223. (arguments
  224. `(#:modules ((guix build utils))
  225. #:builder
  226. (begin
  227. (use-modules (guix build utils))
  228. (let ((target (string-append (assoc-ref %outputs "out")
  229. "/share/texmf-dist/tex/latex/logreq")))
  230. (mkdir-p target)
  231. (copy-recursively (assoc-ref %build-inputs "source") target)
  232. #t))))
  233. (home-page "https://www.ctan.org/pkg/logreq")
  234. (synopsis "Support for automation of the LaTeX workflow")
  235. (description
  236. "The package helps to automate a typical LaTeX workflow that
  237. involves running LaTeX several times, running tools such as BibTeX or
  238. makeindex, and so on. It will log requests like \"please rerun LaTeX\"
  239. or \"please run BibTeX on file X\" to an external XML file which lists
  240. all open tasks in a machine-readable format. Compiler scripts and
  241. integrated LaTeX editing environments may parse this file to determine
  242. the next steps in the workflow in a way that is more efficient than
  243. parsing the main log file. In sum, the package will do two things:
  244. enable package authors to use LaTeX commands to issue requests,
  245. collect all requests from all packages and write them to an external
  246. XML file at the end of the document.")
  247. (license license:lppl1.3)))
  248. (define-public texlive-biblatex
  249. (package
  250. (name "texlive-biblatex")
  251. (version (number->string %texlive-revision))
  252. (source
  253. (origin
  254. (method svn-fetch)
  255. (uri (svn-reference
  256. (url (string-append "svn://www.tug.org/texlive/tags/"
  257. %texlive-tag "/Master/texmf-dist/"
  258. "/tex/latex/biblatex"))
  259. (revision %texlive-revision)))
  260. (file-name (string-append name "-" version "-checkout"))
  261. (sha256
  262. (base32
  263. "116wczqpk3lyc7a18a918bd35pqm4cpngv67xs35g864hp24s7m2"))))
  264. (build-system trivial-build-system)
  265. (arguments
  266. `(#:modules ((guix build utils))
  267. #:builder
  268. (begin
  269. (use-modules (guix build utils))
  270. (let ((target (string-append (assoc-ref %outputs "out")
  271. "/share/texmf-dist/tex/latex/biblatex")))
  272. (mkdir-p target)
  273. (copy-recursively (assoc-ref %build-inputs "source") target)
  274. #t))))
  275. (propagated-inputs
  276. `(("texlive-latex-etoolbox" ,texlive-latex-etoolbox)
  277. ("texlive-url" ,texlive-url)
  278. ("texlive-etex" ,texlive-etex)
  279. ("texlive-logreq" ,texlive-logreq)))
  280. (home-page "https://www.ctan.org/pkg/biblatex")
  281. (synopsis "Process bibliographies for LaTeX")
  282. (description
  283. "BibLaTeX is a complete reimplementation of the bibliographic
  284. facilities provided by LaTeX. Formatting of the bibliography is
  285. entirely controlled by LaTeX macros, and a working knowledge of LaTeX
  286. should be sufficient to design new bibliography and citation
  287. styles. BibLaTeX uses its own data backend program called \"biber\" to
  288. read and process the bibliographic data. With biber, BibLaTeX has many
  289. features rivalling or surpassing other bibliography systems. To
  290. mention a few: Full Unicode support Highly customisable sorting using
  291. the Unicode Collation Algorithm + CLDR tailoring Highly customisable
  292. bibliography labels Complex macro-based on-the-fly data modification
  293. without changing your data sources A tool mode for transforming
  294. bibliographic data sources Multiple bibliographies and lists of
  295. bibliographic information in the same document with different sorting
  296. Highly customisable data source inheritance rules Polyglossia and
  297. babel suppport for automatic language switching for bibliographic
  298. entries and citations Automatic bibliography data recoding (UTF-8 ->
  299. latin1, LaTeX macros -> UTF-8 etc) Remote data sources Highly
  300. sophisticated automatic name and name list disambiguation system
  301. Highly customisable data model so users can define their own
  302. bibliographic data types Validation of bibliographic data against a
  303. data model Subdivided and/or filtered bibligraphies, bibliographies
  304. per chapter, section etc. Apart from the features unique to BibLaTeX,
  305. the package also incorporates core features of the following packages:
  306. babelbib, bibtopic, bibunits, chapterbib, cite, inlinebib, mcite and
  307. mciteplus, mlbib, multibib, splitbib. The package strictly requires
  308. e-TeX BibTeX, bibtex8, or Biber etoolbox 2.1 or later logreq 1.0 or
  309. later keyval ifthen url Biber, babel / polyglossia, and csquotes 4.4
  310. or later are strongly recommended.")
  311. (license license:lppl1.3)))
  312. texlive-biblatex