nix: move to weasypdf from wkhtmltopdf

Closes #1873
This commit is contained in:
Vladimir Timofeenko
2022-12-24 15:42:32 -08:00
parent eca08c7416
commit 5d41d5775c
3 changed files with 63 additions and 5 deletions

View File

@ -178,8 +178,24 @@ let
wkhtmlpdf = {
command = {
program = "${pkgs.wkhtmltopdf}/bin/wkhtmltopdf";
args = [ "-s" "A4" "--encoding" "UTF-8" "-" "{{outfile}}" ];
program = "";
args = [ "--encoding" "UTF-8" "-" "{{outfile}}" ];
timeout = "2 minutes";
};
working-dir = "/tmp/docspell-convert";
};
weasyprint = {
command = {
program = "${pkgs.python310Packages.weasyprint}/bin/weasyprint";
args = [
"--optimize-size"
"all"
"--encoding"
"{{encoding}}"
"-"
"{{outfile}}"
];
timeout = "2 minutes";
};
working-dir = "/tmp/docspell-convert";
@ -1207,6 +1223,11 @@ in
converted to a PDF file.
'';
};
html-converter = mkOption {
type = types.enum [ "wkhtmlpdf" "weasyprint" ];
default = "weasyprint";
description = "Which tool to use for converting html to pdfs";
};
wkhtmlpdf = mkOption {
type = types.submodule ({
options = {
@ -1246,6 +1267,45 @@ in
wkhtmltopdf is used.
'';
};
weasyprint = mkOption {
type = types.submodule ({
options = {
working-dir = mkOption {
type = types.str;
default = defaults.convert.weasyprint.working-dir;
description = "Directory where the conversion processes can put their temp files";
};
command = mkOption {
type = types.submodule ({
options = {
program = mkOption {
type = types.str;
default = defaults.convert.weasyprint.command.program;
description = "The path to the executable.";
};
args = mkOption {
type = types.listOf types.str;
default = defaults.convert.weasyprint.command.args;
description = "The arguments to the program";
};
timeout = mkOption {
type = types.str;
default = defaults.convert.weasyprint.command.timeout;
description = "The timeout when executing the command";
};
};
});
default = defaults.convert.weasyprint.command;
description = "The system command";
};
};
});
default = defaults.convert.weasyprint;
description = ''
To convert HTML files into PDF files, the external tool
weasyprint is used.
'';
};
tesseract = mkOption {
type = types.submodule ({
options = {