Skip to content
Public template

About

Typst flake template with typst, tinymist, typstyle, and pre-commit hooks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typst template

Nix flake template for Typst documents, built on purr and git-hooks.nix. Part of develop-templates.

Setup

Initialize in the current directory:

nix flake init -t "github:nixcafe/develop-templates#typst" --refresh

Or register the template flake once under beans:

nix registry add beans "github:nixcafe/develop-templates"
nix flake init -t beans#typst

If you use cattery-modules, beans is already registered.

To create a new GitHub repository directly:

gh repo create my-typst-project --template nixcafe-develop/typst --clone

Enter the shell:

direnv allow
# or
nix develop

No flake.lock is shipped. The first Nix command generates one.

Build

typst compile main.typ

Watch and rebuild on file changes:

typst watch main.typ

Both write main.pdf, which is ignored in .gitignore.

Tools

Tool Role
typst Typst compiler
tinymist Typst LSP server and preview
typstyle Typst formatter
nixfmt Formats Nix files (nix fmt)
deadnix Finds unused Nix bindings
statix Lints Nix files

Pre-commit hooks for nixfmt, deadnix, statix, and typstyle live in develop/checks/git-hooks/default.nix and install when you enter the shell.

Layout

.
├── .envrc
├── .gitignore
├── flake.nix
├── main.typ
├── statix.toml
└── develop/
    ├── checks/
    │   └── git-hooks/
    │       └── default.nix
    └── shells/
        └── default/
            └── default.nix

Customization

Shell packages

Edit develop/shells/default/default.nix:

packages = with pkgs; [
  typst
  tinymist
  typstyle
  nixfmt
  deadnix
  statix
];

Reload with direnv allow or nix develop.

Pre-commit hooks

Edit develop/checks/git-hooks/default.nix:

{ inputs, system, ... }:
inputs.git-hooks.lib.${system}.run {
  src = ../../..;

  hooks = {
    nixfmt.enable = true;
    deadnix.enable = true;
    statix.enable = true;
    typstyle.enable = true;
  };
}

Commands

nix develop             # open dev shell
typst compile main.typ  # build main.pdf
typst watch main.typ    # rebuild on save
typstyle -i main.typ    # format Typst files
nix fmt                 # format Nix files
nix flake check         # run git-hooks check

About

Typst flake template with typst, tinymist, typstyle, and pre-commit hooks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

Generated from nixcafe-develop/nix