projects/guix·blob java-team · refs

300 lines · 11.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2025 Andrew Wong <[email protected]>
3;;; Copyright © 2025 Alexis Simon <[email protected]>
4;;; Copyright © 2026 Efraim Flashner <[email protected]>
5;;; Copyright © 2026 Liliana Marie Prikler <[email protected]>
6;;;
7;;; This file is part of GNU Guix.
8;;;
9;;; GNU Guix is free software; you can redistribute it and/or modify it
10;;; under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 3 of the License, or (at
12;;; your option) any later version.
13;;;
14;;; GNU Guix is distributed in the hope that it will be useful, but
15;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22(define-module (gnu packages typst)
23 #:use-module (guix packages)
24 #:use-module (guix gexp)
25 #:use-module (guix git-download)
26 #:use-module (guix download)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix build-system cargo)
29 #:use-module (guix build-system copy)
30 #:use-module (guix build-system typst)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages bash)
33 #:use-module (gnu packages llvm)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages rust)
36 #:use-module (gnu packages rust-apps)
37 #:use-module (gnu packages tls))
38
39(define-public prettypst
40 (package
41 (name "prettypst")
42 (version "2.0.0")
43 (source
44 (origin
45 (method git-fetch)
46 (uri (git-reference
47 (url "https://github.com/antonWetzel/prettypst")
48 (commit version)))
49 (file-name (git-file-name name version))
50 (sha256
51 (base32 "0727anhd2wl967m8k5z3bxb37h45nsjbbjz8akjn3mq96cfbfsbw"))))
52 (build-system cargo-build-system)
53 (arguments (list #:install-source? #f))
54 (inputs (cargo-inputs 'prettypst))
55 (home-page "https://github.com/antonWetzel/prettypst")
56 (synopsis "Configurable formatter for Typst")
57 (description
58 "Prettypst is a configurable source file formatter for the Typst
59typesetting system.")
60 (license license:expat)))
61
62(define-public typst
63 (package
64 (name "typst")
65 (version "0.15.0")
66 (source
67 (origin
68 (method git-fetch)
69 (uri (git-reference
70 (url "https://github.com/typst/typst")
71 (commit (string-append "v" version))))
72 (file-name (git-file-name name version))
73 (patches (search-patches "typst-support-GUIX_TYPST_PACKAGE_PATH.patch"))
74 (sha256
75 (base32 "0y727lyicn3ciq36mdpbcg8d09naff39y1i52467mlmr11p0l9xa"))))
76 (build-system cargo-build-system)
77 (arguments
78 (list
79 #:install-source? #f
80 #:imported-modules (append %copy-build-system-modules
81 %cargo-build-system-modules)
82 #:modules '((guix build cargo-build-system)
83 ((guix build copy-build-system) #:prefix copy:)
84 (guix build utils))
85 #:cargo-install-paths ''("crates/typst-cli")
86 #:phases
87 #~(modify-phases %standard-phases
88 (add-after 'unpack 'set-version-string
89 (lambda _
90 (setenv "TYPST_VERSION" #$(package-version this-package))))
91 (add-after 'unpack 'fix-dev-assets
92 (lambda _
93 (substitute* "Cargo.toml"
94 (("typst-dev-assets = \\{[^}]*\\}")
95 (string-append "typst-dev-assets = {version=\""
96 #$version
97 "\"}")))))
98 (add-after 'configure 'configure-artifacts
99 (lambda _
100 (setenv "GEN_ARTIFACTS" (string-append (getcwd) "/artifacts"))))
101 (add-after 'install 'install-artifacts
102 (lambda args
103 (apply (assoc-ref copy:%standard-phases 'install)
104 #:install-plan
105 '(("artifacts/typst.bash"
106 "share/bash-completion/completions/typst")
107 ("artifacts/typst.elv"
108 "share//elvish/lib/typst")
109 ("artifacts/typst.fish"
110 "share/fish/vendor_completions.d/")
111 ("artifacts/_typst"
112 "share/zsh/site-functions/")
113 ("artifacts/" "share/man/man1/"
114 #:include-regexp ("\\.1$")))
115 args))))))
116 (inputs (cons* openssl (cargo-inputs 'typst)))
117 (native-search-paths
118 (list (search-path-specification
119 (variable "GUIX_TYPST_PACKAGE_PATH")
120 (files '("share/typst/packages")))
121 (search-path-specification
122 (variable "TYPST_FONT_PATHS")
123 (files '("share/fonts" "share/texmf-dist/fonts")))))
124 (home-page "https://typst.app/")
125 (synopsis "LaTeX-like typesetting system")
126 (description
127 "Typst is a markup-based typesetting system that is designed to be as
128powerful as LaTeX while being much easier to learn and use. Features include
129built-in markup for math typesetting, bibliography management and other common
130tasks, an extensible scripting system for uncommon tasks, incremental
131compilation, and intuitive error messages.")
132 (license license:asl2.0)))
133
134(define-public typstyle
135 (package
136 (name "typstyle")
137 (version "0.13.10")
138 (source
139 (origin
140 (method url-fetch)
141 (uri (crate-uri "typstyle" version))
142 (file-name (string-append name "-" version ".tar.gz"))
143 (sha256
144 (base32 "06mg12rkls1hkiz8wxchj1jqf1l1bq963s80mrvjfiajb08zqdx1"))))
145 (build-system cargo-build-system)
146 (arguments
147 (list
148 #:install-source? #f
149 #:modules
150 '((guix build cargo-build-system)
151 (guix build utils)
152 (ice-9 match))
153 #:phases
154 #~(modify-phases %standard-phases
155 (add-after 'install 'install-completions
156 (lambda* (#:key native-inputs #:allow-other-keys)
157 (for-each
158 (match-lambda
159 ((shell . path)
160 (mkdir-p (in-vicinity #$output (dirname path)))
161 (let ((binary
162 (if #$(%current-target-system)
163 (search-input-file native-inputs "bin/typstyle")
164 (in-vicinity #$output "bin/typstyle"))))
165 (with-output-to-file (in-vicinity #$output path)
166 (lambda _
167 (invoke binary "completions" shell))))))
168 '(("bash" . "share/bash-completion/completions/typstyle")
169 ("elvish" . "share/elvish/lib/typstyle")
170 ("fish" . "share/fish/vendor_completions.d/typstyle.fish")
171 ("zsh" . "share/zsh/site-functions/_typstyle"))))))))
172 (native-inputs
173 (if (%current-target-system)
174 (list this-package)
175 '()))
176 (inputs (cargo-inputs 'typstyle))
177 (home-page "https://enter-tainer.github.io/typstyle/")
178 (synopsis "Consistent formatter for Typst")
179 (description
180 "Typstyle is a formatter for the Typst typesetting system designed with
181universal consistency and correctness as top priorities. It is
182configuration-free.")
183 (license license:asl2.0)))
184
185(define-public cetz-core-wasm
186 (package
187 (name "cetz-core-wasm")
188 (version "0.5.2")
189 (source
190 (origin
191 (method git-fetch)
192 (uri (git-reference
193 (url "https://github.com/cetz-package/cetz")
194 (commit (string-append "v" version))))
195 (file-name (git-file-name "cetz" version))
196 (sha256
197 (base32 "179nxacfxzkb23h3ikgk0x7m4003913zq64yn6l9zfz5qvfal0sh"))))
198 (build-system cargo-build-system)
199 (arguments
200 (list
201 #:tests? #f ; tests require rand
202 #:phases
203 #~(modify-phases %standard-phases
204 (add-after 'unpack 'chdir
205 (lambda _ (chdir "cetz-core")))
206 (add-after 'configure 'configure-target
207 (lambda* (#:key inputs outputs #:allow-other-keys)
208 (let ((sysroot
209 (assoc-ref inputs
210 "rust-sysroot-for-wasm32-unknown-unknown")))
211 (with-atomic-file-replacement ".cargo/config"
212 (lambda (in out)
213 (display (string-append "\
214[target.wasm32-unknown-unknown]
215linker = 'lld'
216
217[build]
218target = ['wasm32-unknown-unknown']
219") out)
220 (dump-port in out)))
221 (setenv "RUSTFLAGS" (string-append "--sysroot " sysroot)))))
222 (replace 'install
223 (lambda _
224 (install-file
225 (car (find-files "target" "cetz_core.wasm"))
226 (string-append #$output "/share/typst/packages/preview/cetz/"
227 #$version "/cetz-core")))))))
228 (inputs (cargo-inputs 'cetz-core))
229 (native-inputs (list lld rust-sysroot-for-wasm32-unknown-unknown))
230 (home-page "https://cetz-package.github.io")
231 (synopsis "Library for drawing in Typst")
232 (description "CeTZ is a library for drawing figures in Typst,
233similar to TikZ. This package provides the core WebAssembly primitives
234used by the actual CeTZ package.")
235 (license license:lgpl3+)))
236
237(define cetz-common
238 (let ((commit "fa1d1181f45609edf85b9632c18ce950fe87d048"))
239 (origin
240 (method git-fetch)
241 (uri (git-reference
242 (url "https://github.com/cetz-package/common")
243 (commit commit)))
244 (file-name (git-file-name "cetz-common" (string-take commit 7)))
245 (sha256
246 (base32 "16934mjzy5glhw80vm80p1k1dr9l7yyj7s9425j8k3a0awykgyq0")))))
247
248(define-public typst-cetz
249 (package
250 (inherit cetz-core-wasm)
251 (name "typst-cetz")
252 (build-system typst-build-system)
253 (arguments
254 (list #:tests? #f ; tt not yet packaged
255 #:phases
256 #~(modify-phases %standard-phases
257 (add-after 'unpack 'skip-build
258 (lambda _
259 (substitute* "justfile"
260 ((": build") ":"))))
261 (add-after 'unpack 'unpack-scripts
262 (lambda* (#:key inputs #:allow-other-keys)
263 (mkdir-p "common")
264 (copy-recursively (dirname
265 (search-input-file inputs "/scripts/package"))
266 "common/scripts"))))))
267 (propagated-inputs (list cetz-core-wasm typst-oxifmt))
268 (native-inputs (list bash-minimal
269 cetz-common
270 just
271 perl))))
272
273(define-public typst-oxifmt
274 (package
275 (name "typst-oxifmt")
276 (version "1.0.0")
277 (source (origin
278 (method git-fetch)
279 (uri (git-reference
280 (url "https://github.com/PgBiel/typst-oxifmt")
281 (commit (string-append "v" version))))
282 (file-name (git-file-name name version))
283 (sha256
284 (base32 "0mwh8jmck9cxkq9prsjlmxd5msyvfd2a2si4xqc43sqw2dgiqivk"))))
285 (build-system typst-build-system)
286 (arguments
287 (list #:phases
288 #~(modify-phases %standard-phases
289 (replace 'check
290 (lambda* (#:key tests? #:allow-other-keys)
291 (when tests?
292 (invoke "typst" "compile"
293 "--root=."
294 "tests/strfmt-tests.typ")))))))
295 (home-page "https://github.com/PgBiel/typst-oxifmt")
296 (synopsis "Convenient string formatting")
297 (description "This package provides string formatting and interpolation
298through the @code{strfmt} function, with syntax similar to Rust's format
299strings.")
300 (license (list license:expat license:asl2.0))))