-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typst: add initial support for typst packages
- Loading branch information
1 parent
3e7585f
commit b5ab425
Showing
8 changed files
with
220 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ lib, stdenvNoCC }: | ||
{ | ||
nativeBuildInputs ? [ ], | ||
buildInputs ? [ ], | ||
meta ? { }, | ||
... | ||
}@attrs: | ||
let | ||
cleanAttrs = lib.flip lib.removeAttrs [ ]; | ||
typstPkgPrefix = "typst-package"; | ||
in | ||
stdenvNoCC.mkDerivation ( | ||
(cleanAttrs attrs) | ||
// (with attrs; { | ||
name = lib.concatStringsSep "-" [ | ||
typstPkgPrefix | ||
pname | ||
version | ||
]; | ||
installPhase = | ||
let | ||
outDir = "$out/${pname}/${version}"; | ||
in | ||
'' | ||
${attrs.installPhase} | ||
mv $out tmp | ||
mkdir -p ${outDir} | ||
mv -T tmp ${outDir} | ||
''; | ||
}) | ||
) |
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,52 @@ | ||
{ | ||
pkgs, | ||
lib, | ||
stdenvNoCC, | ||
callPackage, | ||
makeBinaryWrapper, | ||
buildTypstPackage, | ||
buildEnv, | ||
}: | ||
|
||
let | ||
cleanAttrs = lib.flip lib.removeAttrs [ ]; | ||
|
||
typstPackages = callPackage ../../../top-level/typst-packages.nix { | ||
callPackage = lib.callPackageWith (pkgs // { inherit buildTypstPackage; }); | ||
}; | ||
|
||
typstPackagesFor = | ||
typst: | ||
lib.makeOverridable ( | ||
{ ... }@typstPkgs: | ||
f: | ||
let | ||
paths = f typstPkgs; | ||
in | ||
buildEnv { | ||
name = "${typst.name}-env"; | ||
|
||
inherit paths; | ||
|
||
nativeBuildInputs = [ makeBinaryWrapper ]; | ||
|
||
postBuild = '' | ||
export _XDG_CACHE_HOME="$out/lib/" | ||
export TYPST_LIB="$_XDG_CACHE_HOME/typst/packages/preview" | ||
mkdir -p $TYPST_LIB | ||
for path in $(find $out -type l); do | ||
mv $path $TYPST_LIB | ||
done | ||
cp -r ${typst}/share $out/share | ||
mkdir -p $out/bin | ||
makeWrapper "${typst}/bin/typst" "$out/bin/typst" --set XDG_CACHE_HOME $_XDG_CACHE_HOME | ||
''; | ||
} | ||
) typstPackages; | ||
in | ||
{ | ||
inherit typstPackages typstPackagesFor; | ||
} |
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,29 @@ | ||
{ buildTypstPackage, fetchFromGitHub }: | ||
|
||
buildTypstPackage rec { | ||
pname = "cetz"; | ||
version = "0.2.2"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "cetz-package"; | ||
repo = "cetz"; | ||
rev = "v${version}"; | ||
hash = "sha256-5+Np64+0Ca8yL7D1CCUewF03Wh6BM2bV1BQNUA+bW74="; | ||
deepClone = true; | ||
}; | ||
|
||
nativeBuildInputs = [ | ||
just | ||
file | ||
perl | ||
]; | ||
|
||
buildPhase = '' | ||
patchShebangs scripts/package | ||
HOME=$(pwd) just install | ||
''; | ||
|
||
installPhase = '' | ||
cp -r .local/share/typst/packages/local/cetz/0.2.2 $out/ | ||
''; | ||
} |
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,18 @@ | ||
{ buildTypstPackage, fetchFromGitHub }: | ||
|
||
buildTypstPackage rec { | ||
pname = "oxifmt"; | ||
version = "0.2.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "PgBiel"; | ||
repo = "typst-oxifmt"; | ||
rev = "v${version}"; | ||
hash = "sha256-OJpkUsoAOHHn7T2O+wICW4nLJ+epkAOfe5R1pMhv1MQ="; | ||
}; | ||
|
||
installPhase = '' | ||
mkdir -p $out | ||
cp -r . $out | ||
''; | ||
} |
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,18 @@ | ||
{ buildTypstPackage, fetchFromGitHub }: | ||
|
||
buildTypstPackage rec { | ||
pname = "polylux"; | ||
version = "0.3.1"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "andreasKroepelin"; | ||
repo = "polylux"; | ||
rev = "v${version}"; | ||
hash = "sha256-jErxl2s2xez2huUwpsT6N1pZANvuZMdIt4taFOurCtU="; | ||
}; | ||
|
||
installPhase = '' | ||
mkdir -p $out | ||
cp -r . $out | ||
''; | ||
} |
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,9 @@ | ||
{ callPackage }: | ||
|
||
{ | ||
polylux = callPackage ../development/typst-packages/polylux.nix { }; | ||
|
||
cetz = callPackage ../development/typst-packages/cetz.nix { }; | ||
|
||
oxifmt = callPackage ../development/typst-packages/oxifmt.nix { }; | ||
} |