summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorTristan Ross <tristan.ross@midstall.com>2025-04-17 23:53:28 -0700
committerGitHub <noreply@github.com>2025-04-17 23:53:28 -0700
commit5bf57e211f39a0e219c756789ed8d915b7e33389 (patch)
treed05e87a61858f57d380c0bb29401923a9bbaefa1 /doc
parenthyprlock: 0.8.0 -> 0.8.1 (#399652) (diff)
parentdoc/languages-frameworks/typst: Format Nix expressions (diff)
downloadnixpkgs-5bf57e211f39a0e219c756789ed8d915b7e33389.tar.gz
doc/languages-frameworks/typst: Format Nix expressions (#399544)
Diffstat (limited to 'doc')
-rw-r--r--doc/languages-frameworks/typst.section.md47
1 files changed, 29 insertions, 18 deletions
diff --git a/doc/languages-frameworks/typst.section.md b/doc/languages-frameworks/typst.section.md
index 1e025be04cc7..3a4910ad8489 100644
--- a/doc/languages-frameworks/typst.section.md
+++ b/doc/languages-frameworks/typst.section.md
@@ -7,10 +7,12 @@ Typst can be configured to include packages from [Typst Universe](https://typst.
You can create a custom Typst environment with a selected set of packages from **Typst Universe** using the following code. It is also possible to specify a Typst package with a specific version (e.g., `cetz_0_3_0`). A package without a version number will always refer to its latest version.
```nix
-typst.withPackages (p: with p; [
- polylux_0_4_0
- cetz_0_3_0
-])
+typst.withPackages (
+ p: with p; [
+ polylux_0_4_0
+ cetz_0_3_0
+ ]
+)
```
### Handling Outdated Package Hashes {#typst-handling-outdated-package-hashes}
@@ -18,18 +20,24 @@ typst.withPackages (p: with p; [
Since **Typst Universe** does not provide a way to fetch a package with a specific hash, the package hashes in `nixpkgs` can sometimes be outdated. To resolve this issue, you can manually override the package source using the following approach:
```nix
-typst.withPackages.override (old: {
- typstPackages = old.typstPackages.extend (_: previous: {
- polylux_0_4_0 = previous.polylux_0_4_0.overrideAttrs (oldPolylux: {
- src = oldPolylux.src.overrideAttrs {
- outputHash = YourUpToDatePolyluxHash;
- };
- });
- });
-}) (p: with p; [
- polylux_0_4_0
- cetz_0_3_0
-])
+typst.withPackages.override
+ (old: {
+ typstPackages = old.typstPackages.extend (
+ _: previous: {
+ polylux_0_4_0 = previous.polylux_0_4_0.overrideAttrs (oldPolylux: {
+ src = oldPolylux.src.overrideAttrs {
+ outputHash = YourUpToDatePolyluxHash;
+ };
+ });
+ }
+ );
+ })
+ (
+ p: with p; [
+ polylux_0_4_0
+ cetz_0_3_0
+ ]
+ )
```
## Custom Packages {#typst-custom-packages}
@@ -39,12 +47,15 @@ typst.withPackages.override (old: {
Here's how to define a custom Typst package:
```nix
-{ buildTypstPackage, typstPackages, fetchzip }:
+{
+ buildTypstPackage,
+ typstPackages,
+}:
buildTypstPackage (finalAttrs: {
pname = "my-typst-package";
version = "0.0.1";
- src = fetchzip { ... };
+ src = ./.;
typstDeps = with typstPackages; [ cetz_0_3_0 ];
})
```