typst: Update typst packages in typst update script

Co-authored-by: emaryn <emaryn@users.noreply.github.com>
This commit is contained in:
Gongqi Huang 2025-05-28 23:09:40 -04:00
parent 4a065b44a0
commit 55333e69a7

View file

@ -5,7 +5,9 @@
installShellFiles, installShellFiles,
pkg-config, pkg-config,
openssl, openssl,
nix-update-script, writeShellScript,
nix-update,
gitMinimal,
versionCheckHook, versionCheckHook,
callPackage, callPackage,
}: }:
@ -60,7 +62,25 @@ rustPlatform.buildRustPackage (finalAttrs: {
versionCheckProgramArg = "--version"; versionCheckProgramArg = "--version";
passthru = { passthru = {
updateScript = nix-update-script { }; updateScript = {
command = [
(writeShellScript "update-typst.sh" ''
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; typst.version or (lib.getVersion typst)" | tr -d '"')
${lib.getExe nix-update} typst > /dev/null
latestVersion=$(nix-instantiate --eval -E "with import ./. {}; typst.version or (lib.getVersion typst)" | tr -d '"')
changes=()
if [[ "$currentVersion" != "$latestVersion" ]]; then
changes+=("{\"attrPath\":\"typst\",\"oldVersion\":\"$currentVersion\",\"newVersion\":\"$latestVersion\",\"files\":[\"pkgs/by-name/ty/typst/package.nix\"]}")
fi
maintainers/scripts/update-typst-packages.py --output pkgs/by-name/ty/typst/typst-packages-from-universe.toml > /dev/null
${lib.getExe gitMinimal} diff --quiet HEAD -- pkgs/by-name/ty/typst/typst-packages-from-universe.toml || changes+=("{\"attrPath\":\"typstPackages\",\"oldVersion\":\"0\",\"newVersion\":\"1\",\"files\":[\"pkgs/by-name/ty/typst/typst-packages-from-universe.toml\"]}")
echo -n "["
IFS=,; echo -n "''${changes[*]}"
echo "]"
'')
];
supportedFeatures = [ "commit" ];
};
packages = callPackage ./typst-packages.nix { }; packages = callPackage ./typst-packages.nix { };
withPackages = callPackage ./with-packages.nix { }; withPackages = callPackage ./with-packages.nix { };
}; };