-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typst: add support to instantiate typst with a set of typst packages
- Loading branch information
1 parent
bb3802b
commit 080f739
Showing
2 changed files
with
103 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
lib, | ||
buildEnv, | ||
typstPackages, | ||
makeBinaryWrapper, | ||
}: | ||
|
||
let | ||
typstPackagesFor = | ||
typst: | ||
lib.makeOverridable ( | ||
{ ... }@typstPkgs: | ||
f: | ||
let | ||
paths = f typstPkgs; | ||
in | ||
buildEnv { | ||
name = "${typst.name}-env"; | ||
|
||
inherit paths; | ||
|
||
nativeBuildInputs = [ makeBinaryWrapper ]; | ||
|
||
postBuild = '' | ||
export TYPST_LIB_DIR="$out/lib/typst/packages" | ||
mkdir -p $TYPST_LIB_DIR/preview | ||
for path in $(find $out -type l); do | ||
mv $path $TYPST_LIB_DIR/preview | ||
done | ||
cp -r ${typst}/share $out/share | ||
mkdir -p $out/bin | ||
makeWrapper "${lib.getExe typst}" "$out/bin/typst" --set TYPST_PACKAGE_CACHE_PATH $TYPST_LIB_DIR | ||
''; | ||
} | ||
) typstPackages; | ||
in | ||
{ | ||
inherit typstPackagesFor; | ||
} |