1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 installShellFiles,
6 pkg-config,
7 openssl,
8 nix-update-script,
9 versionCheckHook,
10 callPackage,
11}:
12
13rustPlatform.buildRustPackage (finalAttrs: {
14 pname = "typst";
15 version = "0.13.1";
16
17 src = fetchFromGitHub {
18 owner = "typst";
19 repo = "typst";
20 tag = "v${finalAttrs.version}";
21 hash = "sha256-vbBwIQt4xWZaKpXgFwDsRQIQ0mmsQPRR39m8iZnnuj0=";
22 };
23
24 cargoHash = "sha256-4kVj2BODEFjLcrh5sxfcgsdLF2Zd3K1GnhA4DEz1Nl4=";
25
26 nativeBuildInputs = [
27 installShellFiles
28 pkg-config
29 ];
30
31 buildInputs = [
32 openssl
33 ];
34
35 env = {
36 GEN_ARTIFACTS = "artifacts";
37 OPENSSL_NO_VENDOR = true;
38 # to not have "unknown hash" in help output
39 TYPST_VERSION = finalAttrs.version;
40 };
41
42 # Fix for "Found argument '--test-threads' which wasn't expected, or isn't valid in this context"
43 postPatch = ''
44 substituteInPlace tests/src/tests.rs --replace-fail 'ARGS.num_threads' 'ARGS.test_threads'
45 substituteInPlace tests/src/args.rs --replace-fail 'num_threads' 'test_threads'
46 '';
47
48 postInstall = ''
49 installManPage crates/typst-cli/artifacts/*.1
50 installShellCompletion \
51 crates/typst-cli/artifacts/typst.{bash,fish} \
52 --zsh crates/typst-cli/artifacts/_typst
53 '';
54
55 cargoTestFlags = [ "--workspace" ];
56
57 doInstallCheck = true;
58 nativeInstallCheckInputs = [ versionCheckHook ];
59 versionCheckProgramArg = "--version";
60
61 passthru = {
62 updateScript = nix-update-script { };
63 packages = callPackage ./typst-packages.nix { };
64 withPackages = callPackage ./with-packages.nix { };
65 };
66
67 meta = {
68 changelog = "https://github.com/typst/typst/releases/tag/v${finalAttrs.version}";
69 description = "New markup-based typesetting system that is powerful and easy to learn";
70 homepage = "https://github.com/typst/typst";
71 license = lib.licenses.asl20;
72 mainProgram = "typst";
73 maintainers = with lib.maintainers; [
74 drupol
75 figsoda
76 kanashimia
77 RossSmyth
78 ];
79 };
80})