1{ lib
2, stdenv
3, fetchFromGitLab
4, fetchpatch
5, nix-update-script
6
7, autoreconfHook
8, pkg-config
9, sphinx
10
11, lerc
12, libdeflate
13, libjpeg
14, libwebp
15, xz
16, zlib
17, zstd
18
19 # for passthru.tests
20, libgeotiff
21, python3Packages
22, imagemagick
23, graphicsmagick
24, gdal
25, openimageio
26, freeimage
27, testers
28}:
29
30stdenv.mkDerivation (finalAttrs: {
31 pname = "libtiff";
32 version = "4.6.0";
33
34 src = fetchFromGitLab {
35 owner = "libtiff";
36 repo = "libtiff";
37 rev = "v${finalAttrs.version}";
38 hash = "sha256-qCg5qjsPPynCHIg0JsPJldwVdcYkI68zYmyNAKUCoyw=";
39 };
40
41 patches = [
42 # FreeImage needs this patch
43 ./headers.patch
44 # libc++abi 11 has an `#include <version>`, this picks up files name
45 # `version` in the project's include paths
46 ./rename-version.patch
47 # Fix static linking of `libtiff` via `pkg-config` not working
48 # because `libtiff` does not declare `Lerc` dependency.
49 # nixpkgs has `lerc` >= 4 which provides a `.pc` file.
50 # TODO: Close when https://gitlab.com/libtiff/libtiff/-/merge_requests/633 is merged and available
51 (fetchpatch {
52 name = "libtiff-4.pc-Fix-Requires.private-missing-Lerc.patch";
53 url = "https://gitlab.com/libtiff/libtiff/-/commit/ea882c3c240c14a897b9be38d815cc1893aafa59.patch";
54 hash = "sha256-C0xA3k1sgKmGJjEnyG9UxhXqYBYShKUDQsyjhbEDJbQ=";
55 })
56 ];
57
58 postPatch = ''
59 mv VERSION VERSION.txt
60 '';
61
62 outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ];
63
64 postFixup = ''
65 moveToOutput include/tif_config.h $dev_private
66 moveToOutput include/tif_dir.h $dev_private
67 moveToOutput include/tif_hash_set.h $dev_private
68 moveToOutput include/tiffiop.h $dev_private
69 '';
70
71 # If you want to change to a different build system, please make
72 # sure cross-compilation works first!
73 nativeBuildInputs = [ autoreconfHook pkg-config sphinx ];
74
75 buildInputs = [
76 lerc
77 zstd
78 ];
79
80 # TODO: opengl support (bogus configure detection)
81 propagatedBuildInputs = [
82 libdeflate
83 libjpeg
84 # libwebp depends on us; this will cause infinite
85 # recursion otherwise
86 (libwebp.override { tiffSupport = false; })
87 xz
88 zlib
89 zstd
90 ];
91
92 enableParallelBuilding = true;
93
94 doCheck = true;
95
96 passthru = {
97 tests = {
98 inherit libgeotiff imagemagick graphicsmagick gdal openimageio freeimage;
99 inherit (python3Packages) pillow imread;
100 pkg-config = testers.hasPkgConfigModules {
101 package = finalAttrs.finalPackage;
102 };
103 };
104 updateScript = nix-update-script { };
105 };
106
107 meta = with lib; {
108 description = "Library and utilities for working with the TIFF image file format";
109 homepage = "https://libtiff.gitlab.io/libtiff";
110 changelog = "https://libtiff.gitlab.io/libtiff/releases/v${finalAttrs.version}.html";
111 license = licenses.libtiff;
112 platforms = platforms.unix ++ platforms.windows;
113 pkgConfigModules = [ "libtiff-4" ];
114 maintainers = teams.geospatial.members;
115 };
116})