1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
{
lib,
buildGoModule,
chromium,
fetchFromGitHub,
libreoffice,
makeBinaryWrapper,
pdftk,
qpdf,
unoconv,
mktemp,
makeFontsConf,
liberation_ttf_v2,
exiftool,
nix-update-script,
}:
let
fontsConf = makeFontsConf { fontDirectories = [ liberation_ttf_v2 ]; };
jre' = libreoffice.unwrapped.jdk;
libreoffice' = "${libreoffice}/lib/libreoffice/program/soffice.bin";
inherit (lib) getExe;
in
buildGoModule rec {
pname = "gotenberg";
version = "8.8.1";
src = fetchFromGitHub {
owner = "gotenberg";
repo = "gotenberg";
rev = "refs/tags/v${version}";
hash = "sha256-vXrSPu/iY6JsOvPKDRdg6TnUjNV7X5GEb5l9bk4lSpY=";
};
vendorHash = "sha256-Hxava/dRQ2TFWrg7fIvRkp3NW61QWmWNEQiBP71wlR8=";
postPatch = ''
find ./pkg -name '*_test.go' -exec sed -i -e 's#/tests#${src}#g' {} \;
'';
nativeBuildInputs = [ makeBinaryWrapper ];
ldflags = [
"-s"
"-w"
"-X github.com/gotenberg/gotenberg/v8/cmd.Version=${version}"
];
checkInputs = [
chromium
libreoffice
pdftk
qpdf
unoconv
mktemp
jre'
];
preCheck = ''
export CHROMIUM_BIN_PATH=${getExe chromium}
export PDFTK_BIN_PATH=${getExe pdftk}
export QPDF_BIN_PATH=${getExe qpdf}
export UNOCONVERTER_BIN_PATH=${getExe unoconv}
export EXIFTOOL_BIN_PATH=${getExe exiftool}
# LibreOffice needs all of these set to work properly
export LIBREOFFICE_BIN_PATH=${libreoffice'}
export FONTCONFIG_FILE=${fontsConf}
export HOME=$(mktemp -d)
export JAVA_HOME=${jre'}
'';
# These tests fail with a panic, so disable them.
checkFlags = [ "-skip=^TestChromiumBrowser_(screenshot|pdf)$" ];
preFixup = ''
wrapProgram $out/bin/gotenberg \
--set PDFTK_BIN_PATH "${getExe pdftk}" \
--set QPDF_BIN_PATH "${getExe qpdf}" \
--set UNOCONVERTER_BIN_PATH "${getExe unoconv}" \
--set EXIFTOOL_BIN_PATH "${getExe exiftool}" \
--set JAVA_HOME "${jre'}"
'';
passthru.updateScript = nix-update-script { };
meta = {
description = "Converts numerous document formats into PDF files";
homepage = "https://gotenberg.dev";
changelog = "https://github.com/gotenberg/gotenberg/releases/tag/v${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ pyrox0 ];
};
}
|