Skip to content

Commit 0df6029

Browse files
committed
flake: fix build derivation
1 parent ffa8996 commit 0df6029

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

flake.nix

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
typst = pkgs.nixpkgs-unstable.typst;
3535

3636
mkTypstScript =
37-
action:
38-
documentName:
37+
action: documentName:
3938
pkgs.writeShellApplication {
4039
name = "typst-${action}-${documentName}";
4140

@@ -56,9 +55,36 @@
5655
'';
5756
};
5857

58+
mkBuildDocumentDrv =
59+
action: documentName:
60+
pkgs.stdenvNoCC.mkDerivation {
61+
pname = "typst-${action}-${documentName}";
62+
version = typst.version;
63+
64+
src = pkgs.lib.cleanSource ./.;
65+
66+
buildInputs = [ typst ];
67+
68+
buildPhase = ''
69+
runHook preBuild
70+
71+
${lib.getExe (mkTypstScript "compile" documentName)}
72+
73+
runHook postBuild
74+
'';
75+
76+
installPhase = ''
77+
runHook preInstall
78+
79+
install -m640 -D ${documentName}.* -t $out
80+
81+
runHook postInstall
82+
'';
83+
};
84+
5985
documentDrvs = lib.genAttrs (lib.attrNames (
6086
lib.filterAttrs (k: v: (v == "directory")) (builtins.readDir ./src)
61-
)) (d: (mkTypstScript "compile" d));
87+
)) (d: (mkBuildDocumentDrv "compile" d));
6288

6389
scriptDrvs =
6490
{

0 commit comments

Comments
 (0)