projects/guix·blob python-team · refs

471 lines · 18.8 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 linguify-fluent-wasm
249 (package
250 (name "linguify-fluent-wasm")
251 (version "0.5.0")
252 (source
253 (origin
254 (method git-fetch)
255 (uri (git-reference
256 (url "https://github.com/typst-community/linguify")
257 (commit (string-append "v" version))))
258 (file-name (git-file-name "linguify" version))
259 (sha256
260 (base32 "105jhaa4k0mq6fxj3aqqavl9jlp70yyxvrz6a7q5p9gcm5zbdpcn"))
261 (snippet #~(delete-file "src/linguify_fluent_rs.wasm"))))
262 (build-system cargo-build-system)
263 (arguments
264 (list
265 #:tests? #f ; no tests
266 #:phases
267 #~(modify-phases %standard-phases
268 (add-after 'configure 'configure-target
269 (lambda* (#:key inputs outputs #:allow-other-keys)
270 (let ((sysroot
271 (assoc-ref inputs
272 "rust-sysroot-for-wasm32-unknown-unknown")))
273 (with-atomic-file-replacement ".cargo/config"
274 (lambda (in out)
275 (display (string-append "\
276[target.wasm32-unknown-unknown]
277linker = 'lld'
278
279[build]
280target = ['wasm32-unknown-unknown']
281") out)
282 (dump-port in out)))
283 (setenv "RUSTFLAGS" (string-append "--sysroot " sysroot)))))
284 (replace 'install
285 (lambda _
286 (install-file
287 (car (find-files "target" "linguify_fluent_rs.wasm"))
288 (string-append #$output "/share/typst/packages/preview/linguify/"
289 #$version)))))))
290 (inputs (cargo-inputs 'linguify-fluent))
291 (native-inputs (list lld rust-sysroot-for-wasm32-unknown-unknown))
292 (home-page "https://typst.app/universe/package/linguify")
293 (synopsis "Easily localize packages and templates")
294 (description "Linguify is a Typst library for loading strings for different
295languages from TOML files.")
296 (license license:expat)))
297
298(define-public typst-cetz
299 (package
300 (inherit cetz-core-wasm)
301 (name "typst-cetz")
302 (version (package-version cetz-core-wasm)) ; to bind in arguments
303 (build-system typst-build-system)
304 (arguments
305 (list
306 #:tests? #f ; tt not yet packaged
307 #:phases
308 #~(modify-phases %standard-phases
309 (add-after 'unpack 'skip-build
310 (lambda _
311 (substitute* "justfile"
312 ((": build") ":"))))
313 (add-after 'unpack 'unpack-scripts
314 (lambda* (#:key inputs #:allow-other-keys)
315 (mkdir-p "common")
316 (copy-recursively (dirname
317 (search-input-file inputs "/scripts/package"))
318 "common/scripts")))
319 (add-after 'install 'symlink-wasm
320 (lambda* (#:key inputs outputs #:allow-other-keys)
321 (let* ((dir (car (find-files #$output "cetz-core"
322 #:directories? #t)))
323 (module
324 (search-path
325 (search-path-as-string->list
326 (getenv "GUIX_TYPST_PACKAGE_PATH"))
327 (string-append
328 "preview/cetz/" #$version "/cetz-core/"
329 "cetz_core.wasm"))))
330 (symlink module
331 (string-append dir "/cetz_core.wasm"))))))))
332 (propagated-inputs (list cetz-core-wasm typst-oxifmt))
333 (native-inputs (list bash-minimal
334 cetz-common
335 just
336 perl))))
337
338(define-public typst-fontawesome
339 (package
340 (name "typst-fontawesome")
341 (version "0.6.2")
342 (source (origin
343 (method git-fetch)
344 (uri (git-reference
345 (url "https://github.com/duskmoon314/typst-fontawesome")
346 (commit (string-append "v" version))))
347 (file-name (git-file-name name version))
348 (sha256
349 (base32 "0pj9jy32vvj9xfz2s6la920nmvm7x70ksbqm5m8ljgfz8fl3m4ix"))))
350 (build-system typst-build-system)
351 (arguments (list #:tests? #f)) ; no tests
352 (home-page "https://github.com/duskmoon314/typst-fontawesome")
353 (synopsis "Typst support for FontAwesome")
354 (description "This package provides a library for using FontAwesome icons
355by their names, similar to texlive-fontawesome for LaTeX.")
356 (license license:expat)))
357
358(define-public typst-larrow
359 (package
360 (name "typst-larrow")
361 (version "1.2.0")
362 (source (origin
363 (method git-fetch)
364 (uri (git-reference
365 (url "https://github.com/Mambouna/larrow")
366 (commit (string-append "v" version))))
367 (file-name (git-file-name name version))
368 (sha256
369 (base32 "1q7w5giivxh3bk03pp2v6z6mpgv9415s284m7di7blz1jnv6hxsc"))))
370 (build-system typst-build-system)
371 (arguments (list #:tests? #f)) ; no tests
372 (propagated-inputs (list typst-cetz))
373 (home-page "https://github.com/Mambouna/larrow")
374 (synopsis "Draw and style arrows between labels")
375 (description "This package provides functions to draw arrows between
376labels.")
377 (license license:mpl2.0)))
378
379(define-public typst-linguify
380 (package
381 (inherit linguify-fluent-wasm)
382 (name "typst-linguify")
383 (version (package-version linguify-fluent-wasm)) ; to bind in arguments
384 (build-system typst-build-system)
385 (arguments
386 (list
387 #:tests? #f ; tests require tt
388 #:phases
389 #~(modify-phases %standard-phases
390 (add-after 'install 'symlink-wasm
391 (lambda* (#:key inputs outputs #:allow-other-keys)
392 (let* ((dir (car (find-files #$output "src" #:directories? #t)))
393 (module
394 (search-path
395 (search-path-as-string->list
396 (getenv "GUIX_TYPST_PACKAGE_PATH"))
397 (string-append
398 "preview/linguify/" #$version "/"
399 "linguify_fluent_rs.wasm"))))
400 (symlink module
401 (string-append dir "/linguify_fluent_rs.wasm"))))))))
402 (inputs (list linguify-fluent-wasm))
403 (native-inputs (list bash-minimal just perl))))
404
405(define-public typst-modern-cv
406 (package
407 (name "typst-modern-cv")
408 (version "0.10.0")
409 (source (origin
410 (method git-fetch)
411 (uri (git-reference
412 (url "https://github.com/ptsouchlos/modern-cv")
413 (commit version)))
414 (file-name (git-file-name name version))
415 (sha256
416 (base32 "03zbwci7l68sd02k45cjjzgzjvr4q0y8aw074bfac897smd13f2v"))))
417 (build-system typst-build-system)
418 (arguments
419 (list #:tests? #f ; tests require tt
420 #:phases
421 #~(modify-phases %standard-phases
422 (add-after 'unpack 'fix-dependencies
423 (lambda* (#:key inputs #:allow-other-keys)
424 (define* (builtin-package-version package #:key
425 (namespace "preview"))
426 (let ((found-pkg (search-input-directory
427 inputs
428 (string-append "share/typst/packages/"
429 namespace "/" package))))
430 (basename (car (find-files found-pkg "^[0-9]*\\.[0-9.]*$"
431 #:directories? #t)))))
432 (substitute* "lib.typ"
433 (("(@preview/fontawesome):[^\"]*" all lib)
434 (string-append lib ":"
435 (builtin-package-version "fontawesome")))))))))
436 (propagated-inputs (list typst-fontawesome typst-linguify))
437 (native-inputs (list bash-minimal just perl))
438 (home-page "https://typst.app/universe/package/linguify")
439 (synopsis "Resume/CV template for Typst")
440 (description "This package provides a resume template for Typst, inspired
441by the Awesome-CV package for LaTeX.")
442 (license license:expat)))
443
444(define-public typst-oxifmt
445 (package
446 (name "typst-oxifmt")
447 (version "1.0.0")
448 (source (origin
449 (method git-fetch)
450 (uri (git-reference
451 (url "https://github.com/PgBiel/typst-oxifmt")
452 (commit (string-append "v" version))))
453 (file-name (git-file-name name version))
454 (sha256
455 (base32 "0mwh8jmck9cxkq9prsjlmxd5msyvfd2a2si4xqc43sqw2dgiqivk"))))
456 (build-system typst-build-system)
457 (arguments
458 (list #:phases
459 #~(modify-phases %standard-phases
460 (replace 'check
461 (lambda* (#:key tests? #:allow-other-keys)
462 (when tests?
463 (invoke "typst" "compile"
464 "--root=."
465 "tests/strfmt-tests.typ")))))))
466 (home-page "https://github.com/PgBiel/typst-oxifmt")
467 (synopsis "Convenient string formatting")
468 (description "This package provides string formatting and interpolation
469through the @code{strfmt} function, with syntax similar to Rust's format
470strings.")
471 (license (list license:expat license:asl2.0))))