nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv
2, fetchurl
3, fetchpatch
4
5, autoreconfHook
6, pkg-config
7
8, libdeflate
9, libjpeg
10, xz
11, zlib
12
13# for passthru.tests
14, libgeotiff
15, python3Packages
16, imagemagick
17, graphicsmagick
18, gdal
19, openimageio
20, freeimage
21, imlib
22}:
23
24#FIXME: fix aarch64-darwin build and get rid of ./aarch64-darwin.nix
25
26stdenv.mkDerivation rec {
27 pname = "libtiff";
28 version = "4.3.0";
29
30 src = fetchurl {
31 url = "https://download.osgeo.org/libtiff/tiff-${version}.tar.gz";
32 sha256 = "1j3snghqjbhwmnm5vz3dr1zm68dj15mgbx1wqld7vkl7n2nfaihf";
33 };
34
35 patches = [
36 # FreeImage needs this patch
37 ./headers.patch
38 # libc++abi 11 has an `#include <version>`, this picks up files name
39 # `version` in the project's include paths
40 ./rename-version.patch
41 (fetchpatch {
42 name = "CVE-2022-22844.patch";
43 url = "https://gitlab.com/libtiff/libtiff/-/commit/03047a26952a82daaa0792957ce211e0aa51bc64.patch";
44 sha256 = "0cfih55f5qpc84mvlwsffik80bgz6drkflkhrdyqq8m84jw3mbwb";
45 })
46 (fetchpatch {
47 name = "CVE-2022-0561.patch";
48 url = "https://gitlab.com/libtiff/libtiff/-/commit/eecb0712f4c3a5b449f70c57988260a667ddbdef.patch";
49 sha256 = "0m57fdxyvhhr9cc260lvkkn2g4zr4n4v9nricc6lf9h6diagd7mk";
50 })
51 (fetchpatch {
52 name = "CVE-2022-0562.patch";
53 url = "https://gitlab.com/libtiff/libtiff/-/commit/561599c99f987dc32ae110370cfdd7df7975586b.patch";
54 sha256 = "0ycirjjc1vigj03kwjb92n6jszsl9p17ccw5hry7lli9gxyyr0an";
55 })
56 (fetchpatch {
57 name = "CVE-2022-0891.patch";
58 url = "https://gitlab.com/libtiff/libtiff/-/commit/46dc8fcd4d38c3b6f35ab28e532aee80e6f609d6.patch";
59 sha256 = "1zn2pgsmbrjx3g2bpdggvwwbp6i348mikwlx4ws482h2379vmyj1";
60 })
61 (fetchpatch {
62 name = "CVE-2022-0865.patch";
63 url = "https://gitlab.com/libtiff/libtiff/-/commit/5e18004500cda10d9074bdb6166b054e95b659ed.patch";
64 sha256 = "131b9ial6avl2agwk31wp2jkrx59955f4r0dikx1jdaywqb7zhd1";
65 })
66 (fetchpatch {
67 name = "CVE-2022-0924.patch";
68 url = "https://gitlab.com/libtiff/libtiff/-/commit/408976c44ef0aad975e0d1b6c6dc80d60f9dc665.patch";
69 sha256 = "1aqaynp74ijxr3rizvbyz23ncs71pbbcw5src1zv46473sy55s8p";
70 })
71 (fetchpatch {
72 name = "CVE-2022-0907.patch";
73 url = "https://gitlab.com/libtiff/libtiff/-/commit/f2b656e2e64adde07a6cffd5c8e96bd81a850fea.patch";
74 sha256 = "0nsplq671qx0f35qww9mx27raqp3nvslz8iv7f3hxdgldylmh2vs";
75 })
76 (fetchpatch {
77 name = "CVE-2022-0909.patch";
78 url = "https://gitlab.com/libtiff/libtiff/-/commit/f8d0f9aa1ba04c9ae3bfe869a18141a8b8117ad7.patch";
79 sha256 = "1plhk6ildl16bp0k3wvzfd4a97hqfqfbbn7vjinsaasf4v0x3q5j";
80 })
81 (fetchpatch {
82 name = "CVE-2022-0908.patch";
83 url = "https://gitlab.com/libtiff/libtiff/-/commit/a95b799f65064e4ba2e2dfc206808f86faf93e85.patch";
84 sha256 = "0i61kkjaixdn2p933lpma9s6i0772vhxjxxcwyqagw96lmszrcm7";
85 })
86 ];
87
88 postPatch = ''
89 mv VERSION VERSION.txt
90 '';
91
92 outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ];
93
94 postFixup = ''
95 moveToOutput include/tif_dir.h $dev_private
96 moveToOutput include/tif_config.h $dev_private
97 moveToOutput include/tiffiop.h $dev_private
98 '';
99
100 # If you want to change to a different build system, please make
101 # sure cross-compilation works first!
102 nativeBuildInputs = [ autoreconfHook pkg-config ];
103
104 propagatedBuildInputs = [ libjpeg xz zlib ]; #TODO: opengl support (bogus configure detection)
105
106 buildInputs = [ libdeflate ];
107
108 enableParallelBuilding = true;
109
110 doCheck = true;
111
112 passthru.tests = {
113 inherit libgeotiff imagemagick graphicsmagick gdal openimageio freeimage imlib;
114 inherit (python3Packages) pillow imread;
115 };
116
117 meta = with lib; {
118 description = "Library and utilities for working with the TIFF image file format";
119 homepage = "https://libtiff.gitlab.io/libtiff";
120 changelog = "https://libtiff.gitlab.io/libtiff/v${version}.html";
121 maintainers = with maintainers; [ qyliss ];
122 license = licenses.libtiff;
123 platforms = platforms.unix;
124 };
125}