nixpkgs/pkgs/build-support/build-typst-package.nix
Krsnik ce440f99cd
typstPackages: skip build phase
Co-authored-by: Gongqi Huang <46938348+cherrypiejam@users.noreply.github.com>
2025-05-12 12:10:45 +02:00

62 lines
1.1 KiB
Nix

{
lib,
stdenvNoCC,
}:
/**
`buildTypstPackage` is a helper builder for typst packages.
# Inputs
`attrs`
: attrs for stdenvNoCC.mkDerivation + typstDeps (a list of `buildTypstPackage` derivations)
# Example
```nix
{ buildTypstPackage, typstPackages }:
buildTypstPackage {
pname = "example";
version = "0.0.1";
src = ./.;
typstDeps = with typstPackages; [ oxifmt ];
}
```
*/
lib.extendMkDerivation {
constructDrv = stdenvNoCC.mkDerivation;
excludeDrvArgNames = [
"typstDeps"
];
extendDrvArgs =
finalAttrs:
{
typstDeps ? [ ],
...
}@attrs:
{
name = "typst-package-${finalAttrs.pname}-${finalAttrs.version}";
dontBuild = true;
installPhase =
let
outDir = "$out/lib/typst-packages/${finalAttrs.pname}/${finalAttrs.version}";
in
''
runHook preInstall
mkdir -p ${outDir}
cp -r . ${outDir}
runHook postInstall
'';
propagatedBuildInputs = typstDeps;
passthru = {
inherit typstDeps;
};
};
}