typst: add support to instantiate typst with a set of typst packages

Changed files
+42 -2
maintainers
pkgs
by-name
top-level
+1 -1
maintainers/scripts/update-typst-packages.py
···
hash=source_hash,
typstDeps=[
self.package_name_full(p, v)
-
for p, v in sorted(self.deps, key=lambda x: x[0])
],
description=self.description,
license=self.license_tokens(),
···
hash=source_hash,
typstDeps=[
self.package_name_full(p, v)
+
for p, v in sorted(self.deps, key=lambda x: (x[0], Version(x[1])))
],
description=self.description,
license=self.license_tokens(),
+6 -1
pkgs/by-name/ty/typst/package.nix
···
xz,
nix-update-script,
versionCheckHook,
}:
rustPlatform.buildRustPackage (finalAttrs: {
···
versionCheckProgramArg = [ "--version" ];
doInstallCheck = true;
-
passthru.updateScript = nix-update-script { };
meta = {
changelog = "https://github.com/typst/typst/releases/tag/v${finalAttrs.version}";
···
xz,
nix-update-script,
versionCheckHook,
+
callPackage,
}:
rustPlatform.buildRustPackage (finalAttrs: {
···
versionCheckProgramArg = [ "--version" ];
doInstallCheck = true;
+
passthru = {
+
updateScript = nix-update-script { };
+
packages = callPackage ./typst-packages.nix { };
+
withPackages = callPackage ./with-packages.nix { };
+
};
meta = {
changelog = "https://github.com/typst/typst/releases/tag/v${finalAttrs.version}";
+33
pkgs/by-name/ty/typst/with-packages.nix
···
···
+
{
+
lib,
+
buildEnv,
+
typstPackages,
+
makeBinaryWrapper,
+
typst,
+
}:
+
+
lib.makeOverridable (
+
{ ... }@typstPkgs:
+
f:
+
buildEnv {
+
name = "${typst.name}-env";
+
+
paths = lib.foldl' (acc: p: acc ++ lib.singleton p ++ p.propagatedBuildInputs) [ ] (f typstPkgs);
+
+
pathsToLink = [ "/lib/typst-packages" ];
+
+
nativeBuildInputs = [ makeBinaryWrapper ];
+
+
postBuild = ''
+
export TYPST_LIB_DIR="$out/lib/typst/packages"
+
mkdir -p $TYPST_LIB_DIR
+
+
mv $out/lib/typst-packages $TYPST_LIB_DIR/preview
+
+
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
+
'';
+
}
+
) typstPackages
+2
pkgs/top-level/all-packages.nix
···
buildTypstPackage = callPackage ../build-support/build-typst-package.nix { };
ueberzug = with python3Packages; toPythonApplication ueberzug;
ueberzugpp = callPackage ../by-name/ue/ueberzugpp/package.nix {
···
buildTypstPackage = callPackage ../build-support/build-typst-package.nix { };
+
typstPackages = typst.packages;
+
ueberzug = with python3Packages; toPythonApplication ueberzug;
ueberzugpp = callPackage ../by-name/ue/ueberzugpp/package.nix {