1{ stdenv, fetchzip, jam, unzip, libX11, libXxf86vm, libXrandr, libXinerama
2, libXrender, libXext, libtiff, libjpeg, libpng, libXScrnSaver, writeText
3, libXdmcp, libXau, lib, openssl, zlib }:
4let
5 version = "1.8.3";
6 in
7stdenv.mkDerivation rec {
8 name = "argyllcms-${version}";
9
10 src = fetchzip {
11 # Kind of flacky URL, it was reaturning 406 and inconsistent binaries for a
12 # while on me. It might be good to find a mirror
13 url = "http://www.argyllcms.com/Argyll_V${version}_src.zip";
14 sha256 = "00ggh47qzb3xyl8rnppwxa6j113lr38aiwvsfyxwgs51aqmvq7bd";
15
16 # The argyllcms web server doesn't like curl ...
17 curlOpts = "--user-agent 'Mozilla/5.0'";
18 };
19
20 patches = [ ./gcc5.patch ];
21
22 # The contents of this file comes from the Jamtop file from the
23 # root of the ArgyllCMS distribution, rewritten to pick up Nixpkgs
24 # library paths. When ArgyllCMS is updated, make sure that changes
25 # in that file is reflected here.
26 jamTop = writeText "argyllcms_jamtop" ''
27 DESTDIR = "/" ;
28 REFSUBDIR = "ref" ;
29
30 # Keep this DESTDIR anchored to Jamtop. PREFIX is used literally
31 ANCHORED_PATH_VARS = DESTDIR ;
32
33 # Tell standalone libraries that they are part of Argyll:
34 DEFINES += ARGYLLCMS ;
35
36 # enable serial instruments & support
37 USE_SERIAL = true ;
38
39 # enable fast serial instruments & support
40 USE_FAST_SERIAL = true ; # (Implicit in USE_SERIAL too)
41
42 # enable USB instruments & support
43 USE_USB = true ;
44
45 # enable dummy Demo Instrument (only if code is available)
46 USE_DEMOINST = true ;
47
48 # Use ArgyllCMS version of libusb (deprecated - don't use)
49 USE_LIBUSB = false ;
50
51 # For testing CCast
52 DEFINES += CCTEST_PATTERN ;
53
54 JPEGLIB = ;
55 JPEGINC = ;
56 HAVE_JPEG = true ;
57
58 TIFFLIB = ;
59 TIFFINC = ;
60 HAVE_TIFF = true ;
61
62 PNGLIB = ;
63 PNGINC = ;
64 HAVE_PNG = true ;
65
66 ZLIB = ;
67 ZINC = ;
68 HAVE_Z = true ;
69
70 SSLLIB = ;
71 SSLINC = ;
72 HAVE_SSL = true ;
73
74 LINKFLAGS +=
75 ${lib.concatStringsSep " " (map (x: "-L${x}/lib") buildInputs)}
76 -ldl -lrt -lX11 -lXext -lXxf86vm -lXinerama -lXrandr -lXau -lXdmcp -lXss
77 -ljpeg -ltiff -lpng -lssl ;
78 '';
79
80 nativeBuildInputs = [ jam unzip ];
81
82 preConfigure = ''
83 cp ${jamTop} Jamtop
84 substituteInPlace Makefile --replace "-j 3" "-j $NIX_BUILD_CORES"
85 # Remove tiff, jpg and png to be sure the nixpkgs-provided ones are used
86 rm -rf tiff jpg png
87
88 unset AR
89 '';
90
91 buildInputs = [
92 libtiff libjpeg libpng libX11 libXxf86vm libXrandr libXinerama libXext
93 libXrender libXScrnSaver libXdmcp libXau openssl
94 ];
95
96 buildFlags = "PREFIX=$(out) all";
97
98 installFlags = "PREFIX=$(out)";
99
100 # Install udev rules, but remove lines that set up the udev-acl
101 # stuff, since that is handled by udev's own rules (70-udev-acl.rules)
102 #
103 # Move ref to a better place (there must be a way to make the install target
104 # do that for us)
105 postInstall = ''
106 rm -v $out/bin/License.txt
107 mkdir -p $out/etc/udev/rules.d
108 sed -i '/udev-acl/d' usb/55-Argyll.rules
109 cp -v usb/55-Argyll.rules $out/etc/udev/rules.d/
110 mkdir -p $out/share/
111 mv $out/ref $out/share/argyllcms
112 '';
113
114 meta = with stdenv.lib; {
115 homepage = http://www.argyllcms.com;
116 description = "Color management system (compatible with ICC)";
117 license = licenses.gpl3;
118 maintainers = [ maintainers.rickynils ];
119 platforms = platforms.linux;
120 };
121}