typstPackages: Use makeScope so that it has typical pkgset attrs

This commit is contained in:
Ross Smyth
2025-11-19 17:10:28 -05:00
parent f569337840
commit d3503bd57f
2 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ Since **Typst Universe** does not provide a way to fetch a package with a specif
```nix
typst.withPackages.override
(old: {
typstPackages = old.typstPackages.extend (
typstPackages = old.typstPackages.overrideScope (
_: previous: {
polylux_0_4_0 = previous.polylux_0_4_0.overrideAttrs (oldPolylux: {
src = oldPolylux.src.overrideAttrs { outputHash = YourUpToDatePolyluxHash; };
+6 -5
View File
@@ -1,13 +1,14 @@
{
lib,
callPackage,
newScope,
}:
let
toPackageName = name: version: "${name}_${lib.replaceStrings [ "." ] [ "_" ] version}";
in
lib.makeExtensible (
final:
lib.makeScope newScope (
self:
lib.recurseIntoAttrs (
lib.foldlAttrs (
packageSet: pname: versionSet:
@@ -16,7 +17,7 @@ lib.makeExtensible (
subPackageSet: version: packageSpec:
subPackageSet
// {
${toPackageName pname version} = callPackage (
${toPackageName pname version} = self.callPackage (
{
lib,
buildTypstPackage,
@@ -32,7 +33,7 @@ lib.makeExtensible (
};
typstDeps = builtins.filter (x: x != null) (
lib.map (d: (lib.attrsets.attrByPath [ d ] null final)) packageSpec.typstDeps
lib.map (d: (lib.attrsets.attrByPath [ d ] null self)) packageSpec.typstDeps
);
meta = {
@@ -46,7 +47,7 @@ lib.makeExtensible (
}
) { } versionSet)
// {
${pname} = final.${toPackageName pname (lib.last (lib.attrNames versionSet))};
${pname} = self.${toPackageName pname (lib.last (lib.attrNames versionSet))};
}
) { } (lib.importTOML ./typst-packages-from-universe.toml)
)