typstPackages: Move recurseIntoAttrs to all-packages

This simplifies the in-derivation logic
This commit is contained in:
Ross Smyth
2025-11-19 15:20:15 -05:00
parent d3503bd57f
commit 057a0e1fb3
2 changed files with 39 additions and 41 deletions

View File

@@ -9,46 +9,44 @@ let
in
lib.makeScope newScope (
self:
lib.recurseIntoAttrs (
lib.foldlAttrs (
packageSet: pname: versionSet:
packageSet
// (lib.foldlAttrs (
subPackageSet: version: packageSpec:
subPackageSet
// {
${toPackageName pname version} = self.callPackage (
{
lib,
buildTypstPackage,
fetchzip,
}:
buildTypstPackage (finalAttrs: {
inherit pname version;
src = fetchzip {
inherit (packageSpec) 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 self)) packageSpec.typstDeps
);
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)
lib.foldlAttrs (
packageSet: pname: versionSet:
packageSet
// (lib.foldlAttrs (
subPackageSet: version: packageSpec:
subPackageSet
// {
${pname} = self.${toPackageName pname (lib.last (lib.attrNames versionSet))};
${toPackageName pname version} = self.callPackage (
{
lib,
buildTypstPackage,
fetchzip,
}:
buildTypstPackage (finalAttrs: {
inherit pname version;
src = fetchzip {
inherit (packageSpec) 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 self)) packageSpec.typstDeps
);
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 { });
})
) { };
}
) { } (lib.importTOML ./typst-packages-from-universe.toml)
)
) { } versionSet)
// {
${pname} = self.${toPackageName pname (lib.last (lib.attrNames versionSet))};
}
) { } (lib.importTOML ./typst-packages-from-universe.toml)
)

View File

@@ -12413,7 +12413,7 @@ with pkgs;
buildTypstPackage = callPackage ../build-support/build-typst-package.nix { };
typstPackages = typst.packages;
typstPackages = recurseIntoAttrs typst.packages;
ueberzug = with python3Packages; toPythonApplication ueberzug;