Skip to content

Commit

Permalink
flake: fix build derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jan 19, 2025
1 parent ffa8996 commit 0df6029
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
typst = pkgs.nixpkgs-unstable.typst;

mkTypstScript =
action:
documentName:
action: documentName:
pkgs.writeShellApplication {
name = "typst-${action}-${documentName}";

Expand All @@ -56,9 +55,36 @@
'';
};

mkBuildDocumentDrv =
action: documentName:
pkgs.stdenvNoCC.mkDerivation {
pname = "typst-${action}-${documentName}";
version = typst.version;

src = pkgs.lib.cleanSource ./.;

buildInputs = [ typst ];

buildPhase = ''
runHook preBuild
${lib.getExe (mkTypstScript "compile" documentName)}
runHook postBuild
'';

installPhase = ''
runHook preInstall
install -m640 -D ${documentName}.* -t $out
runHook postInstall
'';
};

documentDrvs = lib.genAttrs (lib.attrNames (
lib.filterAttrs (k: v: (v == "directory")) (builtins.readDir ./src)
)) (d: (mkTypstScript "compile" d));
)) (d: (mkBuildDocumentDrv "compile" d));

scriptDrvs =
{
Expand Down

0 comments on commit 0df6029

Please sign in to comment.