mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
62 lines
1.1 KiB
Nix
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;
|
|
};
|
|
};
|
|
}
|