typstPackages: Make a dedicated Universe package builder

This commit is contained in:
Ross Smyth
2025-11-19 15:42:44 -05:00
parent 60169950ce
commit 6b482e433f
2 changed files with 49 additions and 25 deletions

View File

@@ -2,31 +2,50 @@
lib,
buildTypstPackage,
fetchzip,
# typstPackages from within the scope
packages,
hash,
description,
license,
typstDeps,
homepage ? null,
typstPackages,
}:
buildTypstPackage (finalAttrs: {
inherit pname version;
lib.extendMkDerivation {
inheritFunctionArgs = false;
constructDrv = buildTypstPackage;
src = fetchzip {
inherit hash;
url = "https://packages.typst.org/preview/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
stripRoot = false;
};
excludeDrvArgNames = [
"description"
"hash"
"license"
"homepage"
"typstDeps"
];
typstDeps = builtins.filter (x: x != null) (
lib.map (d: (lib.attrsets.attrByPath [ d ] null packages)) 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;
};
meta = {
inherit description;
maintainers = with lib.maintainers; [ cherrypiejam ];
license = lib.map (lib.flip lib.getAttr lib.licensesSpdx) license;
}
// (if homepage != null then { inherit homepage; } else { });
})
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

@@ -9,6 +9,10 @@ let
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; };
in
lib.foldlAttrs (
packageSet: pname: versionSet:
packageSet
@@ -16,7 +20,8 @@ lib.makeScope newScope (
subPackageSet: version: packageSpec:
subPackageSet
// {
${toPackageName pname version} = self.callPackage ./build-universe-package.nix {
${toPackageName pname version} = buildUniversePackage {
inherit pname version;
inherit (packageSpec)
hash
description