mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
typst: add fonts to the wrapper
Introduces `typst.wrapper` with the following arguments:
- `packages`. For backwards compatibility, `typst.withPackages f` is
equivalent to `typst.wrapper { packages = f; }`.
- `fonts` allows specifying extra fonts via `TYPST_FONT_PATHS`.
- `extraWrapperArgs` for extra arguments to `makeWrapper`.
This commit is contained in:
@@ -15,6 +15,16 @@ typst.withPackages (
|
||||
)
|
||||
```
|
||||
|
||||
For more customisation options, you can invoke the wrapper directly:
|
||||
|
||||
```nix
|
||||
typst.wrapper {
|
||||
packages = p: [ ];
|
||||
fonts = [ ];
|
||||
extraWrapperArgs = [ ];
|
||||
}
|
||||
```
|
||||
|
||||
### Handling Outdated Package Hashes {#typst-handling-outdated-package-hashes}
|
||||
|
||||
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:
|
||||
|
||||
@@ -71,7 +71,8 @@ rustPlatform.buildRustPackage (finalAttrs: {
|
||||
passthru = {
|
||||
updateScript = nix-update-script { };
|
||||
packages = callPackage ./typst-packages.nix { };
|
||||
withPackages = callPackage ./with-packages.nix { };
|
||||
wrapper = callPackage ./wrapper.nix { };
|
||||
withPackages = ps: finalAttrs.passthru.wrapper { packages = ps; };
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
||||
@@ -8,12 +8,18 @@
|
||||
|
||||
lib.makeOverridable (
|
||||
{ ... }@typstPkgs:
|
||||
f:
|
||||
{
|
||||
packages ? (ps: [ ]),
|
||||
fonts ? [ ],
|
||||
extraWrapperArgs ? [ ],
|
||||
}:
|
||||
buildEnv {
|
||||
inherit (typst) meta;
|
||||
name = "${typst.name}-env";
|
||||
|
||||
paths = lib.foldl' (acc: p: acc ++ lib.singleton p ++ p.propagatedBuildInputs) [ ] (f typstPkgs);
|
||||
paths = lib.foldl' (acc: p: acc ++ lib.singleton p ++ p.propagatedBuildInputs) [ ] (
|
||||
packages typstPkgs
|
||||
);
|
||||
|
||||
pathsToLink = [ "/lib/typst-packages" ];
|
||||
|
||||
@@ -28,7 +34,12 @@ lib.makeOverridable (
|
||||
cp -r ${typst}/share $out/share
|
||||
mkdir -p $out/bin
|
||||
|
||||
makeWrapper "${lib.getExe typst}" "$out/bin/typst" --set TYPST_PACKAGE_CACHE_PATH $TYPST_LIB_DIR
|
||||
TYPST_FONT_PATHS=${lib.escapeShellArg (lib.concatStringsSep ":" fonts)}
|
||||
|
||||
makeWrapper "${lib.getExe typst}" "$out/bin/typst" \
|
||||
--set TYPST_PACKAGE_CACHE_PATH $TYPST_LIB_DIR \
|
||||
''${TYPST_FONT_PATHS:+--set TYPST_FONT_PATHS "$TYPST_FONT_PATHS"} \
|
||||
${lib.escapeShellArgs extraWrapperArgs}
|
||||
'';
|
||||
}
|
||||
) typstPackages
|
||||
Reference in New Issue
Block a user