forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-typst-package.nix
More file actions
62 lines (50 loc) · 1.08 KB
/
build-typst-package.nix
File metadata and controls
62 lines (50 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
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;
};
};
}