Revert "update typst"

This reverts commit 21421e1d37.
This commit is contained in:
2026-01-06 18:11:02 +08:00
parent 21421e1d37
commit ae0b0157cb
4 changed files with 47 additions and 5247 deletions

View File

@@ -1,51 +0,0 @@
{
lib,
buildTypstPackage,
fetchzip,
typstPackages,
}:
lib.extendMkDerivation {
inheritFunctionArgs = false;
constructDrv = buildTypstPackage;
excludeDrvArgNames = [
"description"
"hash"
"license"
"homepage"
"typstDeps"
];
extendDrvArgs =
finalAttrs:
{
pname,
version,
description,
hash,
license,
homepage ? null,
typstDeps ? [ ],
}:
{
src = fetchzip {
inherit hash;
url = "https://packages.typst.org/preview/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
stripRoot = false;
};
typstDeps = builtins.filter (x: x != null) (
lib.map (d: (lib.attrsets.attrByPath [ d ] null typstPackages)) typstDeps
);
meta = {
inherit description;
maintainers = with lib.maintainers; [
cherrypiejam
RossSmyth
];
license = lib.map (lib.flip lib.getAttr lib.licensesSpdx) license;
}
// lib.optionalAttrs (homepage != null) { inherit homepage; };
};
}

View File

@@ -12,13 +12,13 @@
rustPlatform.buildRustPackage (finalAttrs: {
pname = "typst";
version = "0.14.2";
version = "0.14.0";
src = fetchFromGitHub {
owner = "typst";
repo = "typst";
tag = "v${finalAttrs.version}";
hash = "sha256-EXcmL/KNj9vCChCs6RH1J/+aetYcXnEdGEhvVzGNNZA=";
hash = "sha256-Sdl60VNjrSVj8YFZR/b2WOzN8taZ6wsJx5FnED9XQbw=";
leaveDotGit = true;
postFetch = ''
cd $out
@@ -27,7 +27,7 @@ rustPlatform.buildRustPackage (finalAttrs: {
'';
};
cargoHash = "sha256-HDu7/kgpBgUe/CrHm17BkNlg3DYlegTevgAeBCXp6so=";
cargoHash = "sha256-6o7IbDBJU+FGYezfm37Z4eBBWa7G06vFbopI0FqJu7c=";
nativeBuildInputs = [
installShellFiles
@@ -67,6 +67,7 @@ rustPlatform.buildRustPackage (finalAttrs: {
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
passthru = {
updateScript = nix-update-script { };

File diff suppressed because it is too large Load Diff

View File

@@ -1,69 +1,53 @@
{
lib,
callPackage,
newScope,
}:
let
toPackageName = name: version: "${name}_${lib.replaceStrings [ "." ] [ "_" ] version}";
in
lib.makeScope newScope (
self:
let
# Not public, so do not expose to the package set
buildUniversePackage = self.callPackage ./build-universe-package.nix { typstPackages = self; };
lib.makeExtensible (
final:
lib.recurseIntoAttrs (
lib.foldlAttrs (
packageSet: pname: versionSet:
packageSet
// (lib.foldlAttrs (
subPackageSet: version: packageSpec:
subPackageSet
// {
${toPackageName pname version} = callPackage (
{
lib,
buildTypstPackage,
fetchzip,
}:
buildTypstPackage (finalAttrs: {
inherit pname version;
# Creates a versioned package out of a name, version, and packageSpec
makeVersionedPackage = pname: version: packageSpec: {
name = toPackageName pname version;
src = fetchzip {
inherit (packageSpec) hash;
url = "https://packages.typst.org/preview/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
stripRoot = false;
};
value = buildUniversePackage {
homepage = packageSpec.homepage or null;
inherit pname version;
inherit (packageSpec)
hash
description
license
typstDeps
;
};
};
typstDeps = builtins.filter (x: x != null) (
lib.map (d: (lib.attrsets.attrByPath [ d ] null final)) packageSpec.typstDeps
);
# Create a derivation for each package. This is in the format of
# typstPackages.${package}_version
versionedPackages = lib.pipe (lib.importTOML ./typst-packages-from-universe.toml) [
# 1. Create a list of versioned packages
# Only recurse 2 levels deep because the leaf attrs are the pkgspec attrs
(lib.mapAttrsToListRecursiveCond (path: _: (lib.length path) < 2) (
path:
let
# Path is always [ path version ]
pname = lib.head path;
version = lib.last path;
in
makeVersionedPackage pname version
))
# 2. Transform the list into a flat attrset
lib.listToAttrs
];
# Take two version strings and return the newer one
selectNewerVersion = v1: v2: if lib.versionOlder v1 v2 then v2 else v1;
# Select the latest version of each package to represent the
# unversioned derivation in the format of:
# typstPackages.${package}
latestPackages = lib.pipe (lib.importTOML ./typst-packages-from-universe.toml) [
# Take in the attrset of each package and all its versions
# Compare each version and find the latest one.
# Then select it from the versioned package set
(lib.mapAttrs (
pname: versions:
let
latestVersion = lib.foldl' selectNewerVersion "0.0.0" (lib.attrNames versions);
in
versionedPackages.${toPackageName pname latestVersion}
))
];
in
versionedPackages // latestPackages
meta = {
inherit (packageSpec) description;
maintainers = with lib.maintainers; [ cherrypiejam ];
license = lib.map (lib.flip lib.getAttr lib.licensesSpdx) packageSpec.license;
}
// (if packageSpec ? "homepage" then { inherit (packageSpec) homepage; } else { });
})
) { };
}
) { } versionSet)
// {
${pname} = final.${toPackageName pname (lib.last (lib.attrNames versionSet))};
}
) { } (lib.importTOML ./typst-packages-from-universe.toml)
)
)