Using Typst packages
If none of the advice on this page works for you, and there are no open issues related to your problem, feel free to open an issue.
Typst packages are still experimental, so Typix doesn't provide direct support for them yet. However, there are ways you can get them to work.
Typst packages should work out of the box for:
For the other derivation constructors, see below.
Providing the package cache
Typst caches downloaded packages for a given namespace
in {cache-dir}/typst/packages/{namespace}
.
With flake inputs defined like:
{
inputs.typst-packages = {
url = "github:typst/packages";
flake = false;
};
# Contrived example of an additional package repository
inputs.my-typst-packages = {
url = "github:loqusion/my-typst-packages";
flake = false;
};
}
...we can provide them where Typst expects them:
let
typstPackagesSrc = pkgs.symlinkJoin {
name = "typst-packages-src";
paths = [
"${inputs.typst-packages}/packages"
"${inputs.my-typst-packages}/..."
];
};
# You can use this if you only need to use official packages
# typstPackagesSrc = "${inputs.typst-packages}/packages";
typstPackagesCache = pkgs.stdenv.mkDerivation {
name = "typst-packages-cache";
src = typstPackagesSrc;
dontBuild = true;
installPhase = ''
mkdir -p "$out/typst/packages"
cp -LR --reflink=auto --no-preserve=mode -t "$out/typst/packages" "$src"/*
'';
};
in {
build-drv = typixLib.buildTypstProject {
XDG_CACHE_HOME = typstPackagesCache;
# ...
};
build-script = typixLib.buildTypstProjectLocal {
XDG_CACHE_HOME = typstPackagesCache;
# ...
};
}
Then, we can use them in a Typst file like so:
#import "@preview/example:0.1.0"
#import "@loqusion/my-package:0.2.1"