nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 pkgs,
4 buildPythonPackage,
5 fetchFromGitHub,
6 replaceVars,
7 colord,
8 flit-core,
9 pikepdf,
10 pillow,
11 stdenv,
12 exiftool,
13 imagemagick,
14 mupdf-headless,
15 netpbm,
16 numpy,
17 poppler-utils,
18 pytestCheckHook,
19 runCommand,
20 scipy,
21}:
22
23buildPythonPackage rec {
24 pname = "img2pdf";
25 version = "0.6.3";
26 pyproject = true;
27
28 # gitlab.mister-muffin.de produces a 500 error on 0.6.1
29 # when upgrading, switch src attribute back to gitlab if fixed.
30 src = fetchFromGitHub {
31 owner = "josch";
32 repo = "img2pdf";
33 tag = version;
34 hash = "sha256-uHcGCx5DdUxFnATG3T565R+NatLukPPpnRj0TZHToC0=";
35 };
36
37 patches = [
38 (replaceVars ./default-icc-profile.patch {
39 srgbProfile =
40 if stdenv.hostPlatform.isDarwin then
41 "/System/Library/ColorSync/Profiles/sRGB Profile.icc"
42 else
43 # break runtime dependency chain all of colord dependencies
44 runCommand "sRGC.icc" { } ''
45 cp ${colord}/share/color/icc/colord/sRGB.icc $out
46 '';
47 })
48 ];
49
50 build-system = [ flit-core ];
51
52 dependencies = [
53 pikepdf
54 pillow
55 ];
56
57 # FIXME: Only add "sRGB Profile.icc" to __impureHostDeps once
58 # https://github.com/NixOS/nix/issues/9301 is fixed.
59 __impureHostDeps = lib.optionals stdenv.hostPlatform.isDarwin [
60 "/System/Library/ColorSync/Profiles"
61 ];
62
63 nativeCheckInputs = [
64 exiftool
65 pkgs.ghostscript
66 imagemagick
67 mupdf-headless
68 netpbm
69 numpy
70 poppler-utils
71 pytestCheckHook
72 scipy
73 ];
74
75 preCheck = ''
76 export img2pdfprog="$out/bin/img2pdf"
77 '';
78
79 disabledTests = [
80 # https://gitlab.mister-muffin.de/josch/img2pdf/issues/178
81 "test_jpg_cmyk"
82 "test_miff_cmyk8"
83 "test_tiff_cmyk8"
84 "test_miff_cmyk16"
85 "test_png_gray16"
86 "test_png_rgb16"
87 # these only fail on aarch64
88 "test_png_rgba8"
89 "test_png_gray8a"
90 # AssertionError: assert 'resolution' not in ...
91 # (starting with ImagMagick 7.1.2-5)
92 "test_date"
93 "test_jpg"
94 ];
95
96 pythonImportsCheck = [ "img2pdf" ];
97
98 meta = {
99 changelog = "https://gitlab.mister-muffin.de/josch/img2pdf/src/tag/${src.tag}/CHANGES.rst";
100 description = "Convert images to PDF via direct JPEG inclusion";
101 homepage = "https://gitlab.mister-muffin.de/josch/img2pdf";
102 license = lib.licenses.lgpl3Plus;
103 mainProgram = "img2pdf";
104 maintainers = with lib.maintainers; [
105 veprbl
106 dotlambda
107 ];
108 };
109}