watchTypstProject
Returns a derivation for a script that watches an input file and recompiles on changes.
Parameters
Note: All parameters for
writeShellApplication are also supported
(besides text).
emojiFont optional
Specify which emoji font to use. If emojiFont is null, no emoji font will
be included.
May be any of the following:
"twemoji"(default)"twemoji-cbdt""noto""noto-monochrome""emojione"null— Don't include any emoji font (e.g. so you can include your own)
Note about difference between "twemoji" and "twemoji-cbdt"
The default Twemoji font displays color emojis using the SVG font format,
which may not be supported by some systems. If emojis aren't displaying
properly, using "twemoji-cbdt" may fix it.
fontPaths optional
List of sources specifying paths to font files that will be made available to your Typst project. With this, you can compile Typst projects even when the fonts it uses are not available on your system.
Used for setting TYPST_FONT_PATHS (see text#font).
Example
{
outputs = { nixpkgs, typix }: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
watch-script = typix.lib.${system}.watchTypstProject {
fontPaths = [
"${pkgs.roboto}/share/fonts/truetype"
];
};
in {
apps.${system}.default = {
type = "app";
program = lib.getExe watch-script;
};
};
}
forceVirtualPaths optional
If there are any conflicts between virtualPaths and files in your
project directory, they will not be overwritten unless forceVirtualPaths is
true.
Default is false.
scriptName optional
Name of the script that will be added to the Nix store. You can use this name after entering a development shell to invoke the script.
Default is typst-watch.
typstOpts optional
Attrset specifying command-line options to pass to the typst command.
These are in addition to any options you manually pass in
typstWatchCommand.
Default:
{
format = "pdf";
}
Example
{
outputs = { typix }: let
system = "x86_64-linux";
inherit (nixpkgs) lib;
watch-script = typix.lib.${system}.watchTypstProject {
typstOpts = {
format = "png";
ppi = 300;
input = ["key1=value1" "key2=value2"];
};
};
in {
apps.${system}.default = {
type = "app";
program = lib.getExe watch-script;
};
};
}
...will result in a command like:
typst watch --format png --ppi 300 --input key1=value1 --input key2=value2 <source> <output>
typstOutput optional
Destination path for Typst output.
If omitted, it will be inferred from
typstSource — for example,
page.typ will become page.pdf for PDF output.
typstSource optional
Typst input file to compile.
Default is main.typ.
typstWatchCommand optional
Base Typst command to run to watch the project. Other arguments will be appended based on the other parameters you supply.
Default is typst watch.
virtualPaths optional
List of sources that will be made virtually available to your Typst project. Useful for projects which rely on remote resources, such as images or data.
Each element of the list is an attribute set with the following keys:
src: path to source file or directorydest(optional): path where file(s) will be made available (defaults to.)- If
srcis a directory,destwill be a directory containing the files in that directory.- Specifying the same
destfor multiplesrcdirectories will merge them.
- Specifying the same
- If
srcis a file,destwill be a copy of that file.
- If
Instead of an attrset, you may use a path which will be interpreted the same as
if you had specified an attrset with just src.
NOTE: Any paths specified here will not overwrite files in your project
directory, unless you set forceVirtualPaths to true.
Example
You can specify dependencies in your flake input, and then use them in your project with something like:
{
inputs = {
font-awesome = {
url = "github:FortAwesome/Font-Awesome";
flake = false;
};
};
outputs = { nixpkgs, typix, font-awesome }: let
system = "x86_64-linux";
inherit (nixpkgs) lib;
watch-script = typix.lib.${system}.watchTypstProject {
virtualPaths = [
{
dest = "icons";
src = "${font-awesome}/svgs/regular";
}
];
};
in {
apps.${system}.default = {
type = "app";
program = lib.getExe watch-script;
};
};
}
Then, reference the files in Typst:
#image("icons/heart.svg")