typ2docx: init at 0.8.0

Co-authored-by: dotlambda <github@dotlambda.de>
This commit is contained in:
HHR2020
2026-02-06 19:47:05 +08:00
co-authored by dotlambda
parent a3a919e227
commit 6c006d397d
2 changed files with 105 additions and 0 deletions
+88
View File
@@ -0,0 +1,88 @@
{
lib,
python3Packages,
fetchFromGitHub,
fetchurl,
rustPlatform,
pkg-config,
openssl,
pandoc,
}:
python3Packages.buildPythonApplication rec {
pname = "typ2docx";
version = "0.8.0";
pyproject = true;
src = fetchFromGitHub {
owner = "sghng";
repo = "typ2docx";
tag = "v${version}";
hash = "sha256-8Jb13qiS+dpyfJS4m2T6STzORs1VzRKwC8GGgEwiVtU=";
};
lockFile = fetchurl {
url = "https://github.com/sghng/typ2docx/releases/download/v${version}/Cargo.lock";
hash = "sha256-irWv7+uqNyyq42JVLSy9WQz78ynYVsYuQ8fk5nardWw=";
};
cargoDeps = rustPlatform.fetchCargoVendor {
inherit
pname
version
src
postPatch
;
hash = "sha256-Gvdj9izGCem0A3Cy7RBzNzJ57lxk5GRP8I2C2T6RsbY=";
};
postPatch = ''
ln -s ${lockFile} Cargo.lock
'';
nativeBuildInputs = [
rustPlatform.cargoSetupHook
rustPlatform.maturinBuildHook
pkg-config
];
build-system = with python3Packages; [
uv-build
];
dependencies = with python3Packages; [
pdf2docx
pdfservices-sdk
pypdf
rich
saxonche
typer
];
buildInputs = [
openssl
];
makeWrapperArgs = [
"--prefix"
"PATH"
":"
"${lib.makeBinPath [ pandoc ]}"
"--prefix"
"PYTHONPATH"
":"
"$PYTHONPATH"
];
passthru.updateScript = ./update.sh;
meta = {
description = "Convert Math-Rich Typst Project to Microsoft Word Format";
homepage = "https://github.com/sghng/typ2docx";
changelog = "https://github.com/sghng/typ2docx/blob/${src.tag}/CHANGELOG.md";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ hhr2020 ];
mainProgram = "typ2docx";
};
}
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts nix-update jq gnused
set -eou pipefail
currentVersion=$(nix eval --raw -f . typ2docx.version)
latestVersion=$(curl --fail --silent ${GITHUB_TOKEN:+-H "Authorization: Bearer $GITHUB_TOKEN"} https://api.github.com/repos/sghng/typ2docx/releases/latest | jq --raw-output .tag_name | sed 's/^v//')
echo "latest version: $latestVersion"
echo "current version: $currentVersion"
if [[ "$latestVersion" == "$currentVersion" ]]; then
echo "package is up-to-date"
exit 0
fi
update-source-version typ2docx $latestVersion --source-key=lockFile --ignore-same-version
nix-update typ2docx --version skip