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

@ -6,8 +6,6 @@
nixpkgs.config = { nixpkgs.config = {
permittedInsecurePackages = [ permittedInsecurePackages = [
"solr-8.6.3" "solr-8.6.3"
# NOTE: Qtwebkit is a dep for wkhtmltopdf, this line is needed until #201765 is fixed in nixpkgs
"qtwebkit-5.212.0-alpha4"
]; ];
}; };

View File

@ -16,7 +16,7 @@
}; };
# Otherwise oomkiller kills docspell # Otherwise oomkiller kills docspell
virtualisation.memorySize = 2048; virtualisation.memorySize = 4096;
virtualisation.forwardPorts = [ virtualisation.forwardPorts = [
# SSH # SSH

View File

@ -178,8 +178,24 @@ let
wkhtmlpdf = { wkhtmlpdf = {
command = { command = {
program = "${pkgs.wkhtmltopdf}/bin/wkhtmltopdf"; program = "";
args = [ "-s" "A4" "--encoding" "UTF-8" "-" "{{outfile}}" ]; 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"; timeout = "2 minutes";
}; };
working-dir = "/tmp/docspell-convert"; working-dir = "/tmp/docspell-convert";
@ -1207,6 +1223,11 @@ in
converted to a PDF file. 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 { wkhtmlpdf = mkOption {
type = types.submodule ({ type = types.submodule ({
options = { options = {
@ -1246,6 +1267,45 @@ in
wkhtmltopdf is used. 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 { tesseract = mkOption {
type = types.submodule ({ type = types.submodule ({
options = { options = {