Repository navigation
Add more environment control parameters to CLI - #4227
Conversation
|
Tested TYPST_LOCAL_PACKAGES_PATH (rebased on top of 0.11.1) for use in a nix shell, works great! |
|
My original PR also changed the documentation for |
|
I wonder if The usecase would be adding organization wide packages or templates using shared folders, while keeping the user's default package path for other packages. The ignore-default-packages-path, on the other hand, would allow some form of isolation and ease testing. |
Currently, the default path is no longer searched. We considered adding a way to have multiple search paths, which seems useful in principle, but we think this is probably out of scope for this particular PR. Perhaps there could be some per-namespace option, e.g. use |
I'm not sure if distinguishing between those two namespaces is worth it. That would mean that the template import changes not due to network use but due to local path. IMHO, @Local meaning no network access vs @Preview is interesting, but more finegrained control over where the local packages would be fetched should done with the env vars. |
|
Sorry, I didn't mean to imply that those namespace choices I mentioned would be hardcoded or available by default - I meant that you'd be able to pick whichever namespace names you wanted for your own directories of local packages, as is possible today by creating folders other than "local" under |
Oh, I misunderstood! Now I undestand you, and indeed, having access to the root gives the user the option to choose any namespace. |
|
Though with that configuration we're nearing typical compiler flags for linking external packages, rather than typical package manager style configuration for external packages. I wonder whether such path dependencies aren't better put into a |
Being able to configure in a typst.toml the paths for fonts, (extra)packages, etc could be great for some projects. Being able to use env vars IMHO is still convenient when using typst from another app, which would probably send the content to the compiler using stdin, so no document specific files would be used on disk, only resources (fonts, packages, images, etc). |
|
Thank you all! |
|
Excellent !!! Looking forward to using this in Nix :) CC @loqusion (context: https://discourse.nixos.org/t/typix-a-nix-library-for-compiling-typst-projects/40257) |
|
I came across while searching for a solution to the problem that This would solve that issue, from what I read. Cannot wait to have it available in a release! |
That would be a bug; if you can still reproduce it in Typst 0.12-rc2 (the latest release candidate), please open an issue. |
|
Just to be sure: With Edit: It seems 0.12.0 is out. 🎉 I will update and see whether the behaviour is still as I described. |
Co-authored-by: PgBiel <[email protected]> Co-authored-by: Tulio Martins <[email protected]> Co-authored-by: PepinhoJp <[email protected]>
Closes #3892
PR co-authored by @PgBiel , @tulio240 , @PepinhoJp
This PR adds a few parameters to the Typst CLI which lets you control the environment accessed by Typst:
--package-cache-pathor (env)TYPST_PACKAGE_CACHE_PATH: Set this to change where downloaded Typst packages are installed to. For example,#import "@preview/cetz:0.2.2"would downloadcetz:0.2.2to$TYPST_PACKAGE_CACHE_PATH/preview/cetz/0.2.2(instead of the usual$XDG_CACHE_HOME/typst/packages/preview/cetz/0.2.2, on Linux as an example)--package-pathor (env)TYPST_PACKAGE_PATH: Set this to change the root folder where local packages are searched. For example,#import "@local/tablex:0.0.8"would search fortablex:0.0.8at$TYPST_PACKAGE_PATH/local/tablex/0.0.8(instead of the usual$XDG_DATA_HOME/typst/packages/local/tablex/0.0.8, on Linux as an example)--ignore-system-fonts(no env): Specify this to disable searching for system fonts, only use embedded fonts or fonts in specified in--font-path(for
typst updateonly)--backup-pathor (env)TYPST_UPDATE_BACKUP_PATH: Set this to change the file path where the Typst binary is backed up to before an updateWe suggest giving these features a quick test to ensure they work in different environments.
A quick note: We used an
Arcin theFileSlotfield with package storage path information to avoid having to use a reference with a lifetime generic parameter in theFileSlotstruct (since this information is shared between allFileSlot, so didn't want to clone). Let us know if this should be changedCredit to @bluebear94 for the idea of grouping up arguments related to font settings together.