This is a personal tool built on top of existing nixpkgs.typstPackages
infrastructure. Nothing fancy. The main difference of it from typix and other projects is that
- It does automatic dependency resolution for your typst project by going through all your typst source code line by line, use regex to figure out the package you imported.
- And for building, it will recursively collect all dependencies (including transitive dependencies) of your project and build it using
typst.withPackages
infrastructure also standardized innixpkgs
. - It’s simple.
The whole setup is pretty simple, contained in a single flake.nix
file. And you can build doc like this:
self.helpers.buildTypstDoc rec {
inherit pkgs;
src = pkgs.fetchFromGitHub {
owner = "tingerrr";
repo = "anti-matter";
rev = "v${version}";
hash = "sha256-J1ByutA/0ciP4/Q1N6ZJ71YNZpOH4XjxsD0+7DHl69M=";
};
main = "./docs/manual.typ";
version = "0.1.1";
pname = "anti-matter-manual";
}
and it will build the doc while handling all dependencies for you automatically:
$ nix build .\#anti-matter-manual
trace: [typst2nix] extracted dependency typst-package-tidy-0.1.0 from source
trace: [typst2nix] extracted dependency typst-package-hydra-0.2.0 from source
trace: [typst2nix] found typst-package-hydra-0.2.0 depends on typst-package-oxifmt-0.2.0
trace: [typst2nix] extracted dependency typst-package-oxifmt-0.2.0 from source
See further details in my repo GitHub - LEXUGE/typst2nix: Package Management and Tooling for Typst implemented in Nix