Unverified Commit 0b745514 authored by Naïm Camille Favier's avatar Naïm Camille Favier Committed by GitHub
Browse files

typst: add `fonts` to the wrapper (#481751)

parents c7cbacc1 6a918ec2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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:
+2 −1
Original line number Diff line number Diff line
@@ -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 = {
+14 −3
Original line number Diff line number Diff line
@@ -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