Press: Nix overlay for building Typst documents and using any Typst package

Hello, I have finished up the first version of my little Nix overlay. It builds documents, and allows for you to use any package you want, not just ones in Typst Universe.

The main problem I had was using private packages was cumbersome. I came up with a way in #4040, and then just generalized it.

It’s pretty easy to use. First you must apply the overlay to your nixpkgs instance.

pkgs = import nixpkgs {
    inherit system;
    overlays = [ (import press) ];
}

Then you create your document’s derivation:

document = pkgs.buildTypstDocument {
  src = ./;
};

If you want to add non-Universe packages, add them in the extraPackage attribute:

document = pkgs.buildTypstDocument {
  src = ./.;
  extraPackages = { local = [ myPackage ]; };
};

Along with other options described here.

It is definitely not done, but it is enough for me to use it usefully. Things I plan on adding:

  1. Adding fonts to the build environment (I have a WIP branch)
  2. Patching

I just released v1.1 which includes custom font support

v1.2 was just released which includes support for patching Typst Unvierse

Alright I’d basically call it feature complete. Let me know if there’s anything people want.

New release: devShell support

Late forum post,

Release v2.0: Nixpkgs typstPackages support
Recently, Nixpkgs merged all packages in Typst Universe into the repo.

This is very convenient for me because that means that rather than pulling in the entire Universe repo, the user can not specify what exactly they would like. So here it is

Changes:

  1. No longer vendor Typst Universe into the nix store for every document
    Documents should build much faster now.
  2. [Breaking] Remove unused or deprecated attributes
    typstPatches, typstUniverse, and universePatches
  3. Add verbose attribute
    Controls how verbose the Typst compiler session is
  4. Add nice assert messages
  5. [Breaking] Remove support for all the different datatypes for the extraPackages key.
    It used to accept a value, a list, an attributeset of values, and an attribute set of lists. Now it only accepts an attribute set of lists.

See the template for full details, but essentially it looks like this now:

pkgs.buildTypstDocument {
    name = "foo";
    src = ./.;
    typstEnv = p: [ p.note-me ];
}

Regressions:
This package does not scan the custom packages pulled in. This means that if you use a custom package that relies on having a Universe package that is not added to typstEnv, compilation will fail. Tracked in #10