File tree Expand file tree Collapse file tree 4 files changed +25
-0
lines changed Expand file tree Collapse file tree 4 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 23
23
"extraPackages"
24
24
"fonts"
25
25
"typstEnv"
26
+ "inputs"
26
27
] ;
27
28
28
29
# All the drv args
37
38
typstEnv ? ( _ : [ ] ) ,
38
39
extraPackages ? { } ,
39
40
file ? "main.typ" ,
41
+ inputs ? { } ,
40
42
format ? "pdf" ,
41
43
...
42
44
} @args :
110
112
111
113
typst c ${ file } ${ lib . optionalString verbose "--verbose" } ${
112
114
lib . optionalString ( format == "html" ) "--features html"
115
+ } ${
116
+ lib . concatStringsSep " " (
117
+ lib . mapAttrsToList ( name : value : "--input ${ name } =${ lib . escapeShellArg value } " ) inputs
118
+ )
113
119
} -f ${ format } $out
114
120
115
121
runHook postBuild
Original file line number Diff line number Diff line change 43
43
# This is relative to the directory input above.
44
44
# Default: "main.typ"
45
45
file = "main.typ" ;
46
+ # [Optional] Key-value attribute set passed as --input arguments to typst
47
+ # (available as the `sys.inputs` dictionary)
48
+ inputs = {
49
+ "language" = "fr" ;
50
+ } ;
46
51
# [Optional] Typst universe package selection
47
52
#
48
53
# Pass in a function that accept an attrset of Typst pacakges,
Original file line number Diff line number Diff line change 95
95
local = [ note-meGh ] ;
96
96
} ;
97
97
} ;
98
+
99
+ inputs = mkTest {
100
+ name = "inputs" ;
101
+ inputs = {
102
+ language = "en" ;
103
+ name = "John Doe" ;
104
+ } ;
105
+ } ;
106
+
98
107
}
Original file line number Diff line number Diff line change
1
+ Value of "sys.inputs.language" is #sys.inputs.language
2
+
3
+ #if sys.inputs.name != "John Doe" {
4
+ panic("Expected 'John Doe' in 'sys.inputs.name' but got " + sys.inputs.flag)
5
+ }
You can’t perform that action at this time.
0 commit comments