From 7a27565b0d52d71feecf948f5c332faa1ae41213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 30 Jul 2025 12:29:49 +0200 Subject: [PATCH] typst-bot: refactor --- nix/packages/by-name/typst-bot/package.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/nix/packages/by-name/typst-bot/package.nix b/nix/packages/by-name/typst-bot/package.nix index 2f8920a0..4d831097 100644 --- a/nix/packages/by-name/typst-bot/package.nix +++ b/nix/packages/by-name/typst-bot/package.nix @@ -1,11 +1,16 @@ { - rustPlatform, - fetchFromGitHub, lib, + rustPlatform, + runCommand, + fetchFromGitHub, }: let rev = "6be5470fcb19e857f76ede9a7f0c96cac63e3abc"; in - rustPlatform.buildRustPackage (finalAttrs: { + rustPlatform.buildRustPackage (finalAttrs: let + fontDrv = runCommand "typst-bot-font" {} '' + cp -r ${finalAttrs.src}/fonts $out + ''; + in { pname = "typst-bot"; version = lib.substring 0 8 rev; @@ -21,11 +26,10 @@ in echo 'fn main() { println!("cargo:rustc-env=BUILD_SHA=${rev}"); }' > crates/bot/build.rs # Patch the fonts with src - # FIXME: is this the right way to patch - substituteInPlace crates/worker/src/sandbox.rs --replace-fail 'read_dir("fonts")' 'read_dir("${finalAttrs.src}/fonts")' + substituteInPlace crates/worker/src/sandbox.rs --replace-fail 'read_dir("fonts")' 'read_dir("${fontDrv}")' # Patch the command calling the worker by name. - substituteInPlace crates/bot/src/worker.rs --replace-fail 'Command::new("./worker")' 'Command::new("worker")' + substituteInPlace crates/bot/src/worker.rs --replace-fail 'Command::new("./worker")' 'Command::new("${placeholder "out"}/bin/worker")' ''; cargoBuildFlags = ["--workspace"];