1{ stdenv, fetchzip, jam, unzip, libX11, libXxf86vm, libXrandr, libXinerama
2, libXrender, libXext, libtiff, libjpeg, libpng, libXScrnSaver, writeText
3, libXdmcp, libXau, lib, openssl }:
4
5stdenv.mkDerivation rec {
6 pname = "argyllcms";
7 version = "2.3.1";
8
9 src = fetchzip {
10 # Kind of flacky URL, it was reaturning 406 and inconsistent binaries for a
11 # while on me. It might be good to find a mirror
12 url = "https://www.argyllcms.com/Argyll_V${version}_src.zip";
13 sha256 = "sha256-XWsubjdD1tg0o7x/aoAalemAChehWkwh4fkP2WRvhAw=";
14 };
15
16 nativeBuildInputs = [ jam unzip ];
17
18 postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
19 substituteInPlace Jambase \
20 --replace "-m64" ""
21 '';
22
23 preConfigure = let
24 # The contents of this file comes from the Jamtop file from the
25 # root of the ArgyllCMS distribution, rewritten to pick up Nixpkgs
26 # library paths. When ArgyllCMS is updated, make sure that changes
27 # in that file is reflected here.
28 jamTop = writeText "argyllcms_jamtop" ''
29 DESTDIR = "/" ;
30 REFSUBDIR = "share/argyllcms" ;
31
32 # Keep this DESTDIR anchored to Jamtop. PREFIX is used literally
33 ANCHORED_PATH_VARS = DESTDIR ;
34
35 # Tell standalone libraries that they are part of Argyll:
36 DEFINES += ARGYLLCMS ;
37
38 # enable serial instruments & support
39 USE_SERIAL = true ;
40
41 # enable fast serial instruments & support
42 USE_FAST_SERIAL = true ; # (Implicit in USE_SERIAL too)
43
44 # enable USB instruments & support
45 USE_USB = true ;
46
47 # enable dummy Demo Instrument (only if code is available)
48 USE_DEMOINST = true ;
49
50 # enable Video Test Patch Generator and 3DLUT device support
51 # (V2.0.0 and above)
52 USE_VTPGLUT = false ;
53
54 # enable Printer device support
55 USE_PRINTER = false ;
56
57 # enable CMF Measurement device and accessory support (if present)
58 USE_CMFM = false ;
59
60 # Use ArgyllCMS version of libusb (deprecated - don't use)
61 USE_LIBUSB = false ;
62
63 # Compile in graph plotting code (Not fully implemented)
64 USE_PLOT = true ; # [true]
65
66 JPEGLIB = ;
67 JPEGINC = ;
68 HAVE_JPEG = true ;
69
70 TIFFLIB = ;
71 TIFFINC = ;
72 HAVE_TIFF = true ;
73
74 PNGLIB = ;
75 PNGINC = ;
76 HAVE_PNG = true ;
77
78 ZLIB = ;
79 ZINC = ;
80 HAVE_Z = true ;
81
82 SSLLIB = ;
83 SSLINC = ;
84 HAVE_SSL = true ;
85
86 LINKFLAGS +=
87 ${lib.concatStringsSep " " (map (x: "-L${x}/lib") buildInputs)}
88 -lrt -lX11 -lXext -lXxf86vm -lXinerama -lXrandr -lXau -lXdmcp -lXss
89 -ljpeg -ltiff -lpng -lssl ;
90 '';
91 in ''
92 cp ${jamTop} Jamtop
93 substituteInPlace Makefile --replace "-j 3" "-j $NIX_BUILD_CORES"
94 # Remove tiff, jpg and png to be sure the nixpkgs-provided ones are used
95 rm -rf tiff jpg png
96
97 export AR="$AR rusc"
98 '';
99
100 buildInputs = [
101 libtiff libjpeg libpng libX11 libXxf86vm libXrandr libXinerama libXext
102 libXrender libXScrnSaver libXdmcp libXau openssl
103 ];
104
105 buildFlags = [ "all" ];
106
107 makeFlags = [
108 "PREFIX=${placeholder "out"}"
109 ];
110
111 # Install udev rules, but remove lines that set up the udev-acl
112 # stuff, since that is handled by udev's own rules (70-udev-acl.rules)
113 postInstall = ''
114 rm -v $out/bin/License.txt
115 mkdir -p $out/etc/udev/rules.d
116 sed -i '/udev-acl/d' usb/55-Argyll.rules
117 cp -v usb/55-Argyll.rules $out/etc/udev/rules.d/
118
119 sed -i -e 's/^CREATED .*/CREATED "'"$(date -d @$SOURCE_DATE_EPOCH)"'"/g' $out/share/argyllcms/RefMediumGamut.gam
120
121 '';
122
123 meta = with lib; {
124 homepage = "http://www.argyllcms.com";
125 description = "Color management system (compatible with ICC)";
126 license = licenses.gpl3;
127 maintainers = [];
128 platforms = platforms.linux;
129 };
130}