Declaring a shell environment

You can automatically pull your project's dependencies into your shell by declaring a shell environment and then activating it with nix develop or direnv.

Here's an example in a flake using Typix's devShell:

{
  outputs = { typix }: let
    system = "x86_64-linux";
    typixLib = typix.lib.${system};

    watch-script = typixLib.watchTypstProject {/* ... */};
  in {
    # packages, apps, etc. omitted

    devShells.${system}.default = typixLib.devShell {
      fontPaths = [/* ... */];
      virtualPaths = [/* ... */];
      packages = [
        watch-script
      ];
    };
  };
}

What this example does:

  • Fonts added to fontPaths will be made available to typst commands via the TYPST_FONT_PATHS environment variable.
  • Files in virtualPaths will be recursively symlinked to the current directory (only overwriting existing files when forceVirtualPaths is true).
  • For convenience, the typst-watch script is added, which will run watchTypstProject.