Skip to content

Commit

Permalink
chore: simplify Nix file, remove custom typst-wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 15, 2024
1 parent 7276777 commit ee72377
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,26 @@
];
};

typst-wrapper-factory =
typstDrv: typst-packages: typstFontPaths:
pkgs.writeShellApplication {
name = "typst-wrapper";

runtimeInputs = [
typstDrv
typst-packages
];

text = ''
TYPST_FONT_PATHS=${typstFontPaths} TYPST_PACKAGE_PATH=${typst-packages} ${lib.getExe typstDrv} "$@"
'';
};

typst-wrapper = typst-wrapper-factory typst config.packages.typst-packages fontsConf;

mkBuildDocumentDrv =
documentName:
pkgs.stdenvNoCC.mkDerivation {
name = "build-" + documentName;

src = pkgs.lib.cleanSource ./.;

buildInputs = [ typst-wrapper ];
buildInputs = [ typst ];

buildPhase = ''
runHook preBuild
${lib.getExe typst-wrapper} \
${lib.getExe typst} \
compile \
--root ./. \
--input rev="${inputs.self.rev or ""}" \
--input shortRev="${inputs.self.shortRev or ""}" \
--input builddate="$(date -u -d @${toString (inputs.self.lastModified or "")})" \
--package-path ${inputs.typst-packages}/packages \
--font-path ${fontsConf} \
--ignore-system-fonts \
./src/${documentName}/main.typ \
${documentName}.pdf
Expand All @@ -101,16 +85,18 @@
pkgs.writeShellApplication {
name = "build-${documentName}";

runtimeInputs = [ typst-wrapper ];
runtimeInputs = [ typst ];

text = ''
${lib.getExe typst-wrapper} \
${lib.getExe typst} \
compile \
--root ./. \
--input rev="${inputs.self.rev or ""}" \
--input shortRev="${inputs.self.shortRev or ""}" \
--input builddate="$(date -u -d @${toString (inputs.self.lastModified or "")})" \
--package-path ${inputs.typst-packages}/packages \
--font-path ${fontsConf} \
--ignore-system-fonts \
./src/${documentName}/main.typ \
${documentName}.pdf
'';
Expand All @@ -121,16 +107,18 @@
pkgs.writeShellApplication {
name = "watch-${documentName}";

runtimeInputs = [ typst-wrapper ];
runtimeInputs = [ typst ];

text = ''
${lib.getExe typst-wrapper} \
${lib.getExe typst} \
watch \
--root ./. \
--input rev="${inputs.self.rev or ""}" \
--input shortRev="${inputs.self.shortRev or ""}" \
--input builddate="$(date -u -d @${toString (inputs.self.lastModified or "")})" \
--package-path ${inputs.typst-packages}/packages \
--font-path ${fontsConf} \
--ignore-system-fonts \
./src/${documentName}/main.typ \
${documentName}.pdf
'';
Expand Down Expand Up @@ -160,7 +148,6 @@
devShells.default = pkgs.mkShellNoCC {
packages = (lib.attrValues scriptDrvs) ++ [
typst
typst-wrapper
pkgs.gnuplot
config.packages.weasel
config.packages.passive
Expand All @@ -170,7 +157,6 @@
shellHook = ''
echo "Typst version: ${typst.version}"
echo "Typst bin: ${lib.getExe typst}"
echo "Typst wrapper bin: ${lib.getExe typst-wrapper}"
echo "Typst packages directory: ${config.packages.typst-packages}"
echo "Typst fonts directory: ${fontsConf}"
'';
Expand Down

0 comments on commit ee72377

Please sign in to comment.