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