Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenvNoCC,
4}:
5
6/**
7 `buildTypstPackage` is a helper builder for typst packages.
8
9 # Inputs
10
11 `attrs`
12 : attrs for stdenvNoCC.mkDerivation + typstDeps (a list of `buildTypstPackage` derivations)
13
14 # Example
15 ```nix
16 { buildTypstPackage, typstPackages }:
17
18 buildTypstPackage {
19 pname = "example";
20 version = "0.0.1";
21 src = ./.;
22 typstDeps = with typstPackages; [ oxifmt ];
23 }
24 ```
25*/
26
27lib.extendMkDerivation {
28 constructDrv = stdenvNoCC.mkDerivation;
29
30 excludeDrvArgNames = [
31 "typstDeps"
32 ];
33
34 extendDrvArgs =
35 finalAttrs:
36 {
37 typstDeps ? [ ],
38 ...
39 }@attrs:
40 {
41 name = "typst-package-${finalAttrs.pname}-${finalAttrs.version}";
42
43 dontBuild = true;
44
45 installPhase =
46 let
47 outDir = "$out/lib/typst-packages/${finalAttrs.pname}/${finalAttrs.version}";
48 in
49 ''
50 runHook preInstall
51 mkdir -p ${outDir}
52 cp -r . ${outDir}
53 runHook postInstall
54 '';
55
56 propagatedBuildInputs = typstDeps;
57
58 passthru = {
59 inherit typstDeps;
60 };
61 };
62}