diff options
author | Wael M. Nasreddine <wael.nasreddine@gmail.com> | 2022-07-13 14:58:42 -0700 |
---|---|---|
committer | Wael M. Nasreddine <wael.nasreddine@gmail.com> | 2022-07-14 11:14:00 -0700 |
commit | c67eb446daa24665dd0599cc9cba2ae4ad7a7d4f (patch) | |
tree | 8871099f9c2bd30c18f701f1622b7e47c5b628af /pkgs/tools/graphics/wkhtmltopdf-bin | |
parent | e703a434b7210164d8042585509b6e87eb3fadb6 (diff) |
wkhtmltopdf-bin: add support for Linux
Diffstat (limited to 'pkgs/tools/graphics/wkhtmltopdf-bin')
-rw-r--r-- | pkgs/tools/graphics/wkhtmltopdf-bin/default.nix | 91 |
1 files changed, 71 insertions, 20 deletions
diff --git a/pkgs/tools/graphics/wkhtmltopdf-bin/default.nix b/pkgs/tools/graphics/wkhtmltopdf-bin/default.nix index 3c2b446a8e1c7..2218d2528c033 100644 --- a/pkgs/tools/graphics/wkhtmltopdf-bin/default.nix +++ b/pkgs/tools/graphics/wkhtmltopdf-bin/default.nix @@ -1,28 +1,76 @@ -{ stdenv, lib, fetchurl, wkhtmltopdf, xar, cpio }: +{ lib +, autoPatchelfHook +, cpio +, freetype +, zlib +, openssl +, dpkg +, fetchurl +, gcc-unwrapped +, libjpeg8 +, libpng +, fontconfig +, stdenv +, wkhtmltopdf +, xar +, xorg +}: -stdenv.mkDerivation rec { +let + darwinAttrs = rec { + version = "0.12.6-2"; + src = fetchurl { + url = "https://github.com/wkhtmltopdf/packaging/releases/download/${version}/wkhtmltox-${version}.macos-cocoa.pkg"; + sha256 = "sha256-gaZrd7UI/t6NvKpnEnIDdIN2Vos2c6F/ZhG21R6YlPg="; + }; - pname = "wkhtmltopdf-bin"; - version = "0.12.6-1"; - sha256 = "1db59kdprzpmvdj1bg47lmfgi3zlvzvqif11sbym9hw61xy6gp3d"; - src = fetchurl { - url = - "https://github.com/wkhtmltopdf/packaging/releases/download/${version}/wkhtmltox-${version}.macos-cocoa.pkg"; - inherit sha256; + nativeBuildInputs = [ xar cpio ]; + + unpackPhase = '' + xar -xf $src + zcat Payload | cpio -i + tar -xf usr/local/share/wkhtmltox-installer/wkhtmltox.tar.gz + ''; + + installPhase = '' + mkdir -p $out + cp -r bin include lib share $out/ + ''; }; - buildInputs = [ xar cpio ]; + linuxAttrs = rec { + version = "0.12.6-3"; + src = fetchurl { + url = "https://github.com/wkhtmltopdf/packaging/releases/download/${version}/wkhtmltox-${version}.archlinux-x86_64.pkg.tar.xz"; + sha256 = "sha256-6Ewu8sPRbqvYWj27mBlQYpEN+mb+vKT46ljrdEUxckI="; + }; - unpackPhase = '' - xar -xf $src - zcat Payload | cpio -i - tar -xf usr/local/share/wkhtmltox-installer/wkhtmltox.tar.gz - ''; + nativeBuildInputs = [ autoPatchelfHook ]; - installPhase = '' - mkdir -p $out - cp -r bin include lib share $out/ - ''; + buildInputs = [ + xorg.libXext + xorg.libXrender + + freetype + openssl + zlib + + (lib.getLib fontconfig) + (lib.getLib gcc-unwrapped) + (lib.getLib libjpeg8) + (lib.getLib libpng) + ]; + + unpackPhase = "tar -xf $src"; + + installPhase = '' + mkdir -p $out + cp -r usr/bin usr/include usr/lib usr/share $out/ + ''; + }; +in +stdenv.mkDerivation ({ + pname = "wkhtmltopdf-bin"; dontStrip = true; @@ -46,6 +94,9 @@ stdenv.mkDerivation rec { ''; license = licenses.gpl3Plus; maintainers = with maintainers; [ nbr ]; - platforms = [ "x86_64-darwin" ]; + platforms = [ "x86_64-darwin" "x86_64-linux" ]; }; } +// lib.optionalAttrs (stdenv.hostPlatform.isDarwin) darwinAttrs +// lib.optionalAttrs (stdenv.hostPlatform.isLinux) linuxAttrs +) |