zoxide: 0.9.6 -> 0.9.7 (#380745)
[NixPkgs.git] / pkgs / by-name / ar / argyllcms / package.nix
blobf430676270222fe42694b97031d136d7c702d946
2   stdenv,
3   fetchzip,
4   jam,
5   unzip,
6   libX11,
7   libXxf86vm,
8   libXrandr,
9   libXinerama,
10   libXrender,
11   libXext,
12   libtiff,
13   libjpeg,
14   libpng,
15   libXScrnSaver,
16   writeText,
17   libXdmcp,
18   libXau,
19   lib,
20   openssl,
21   buildPackages,
22   replaceVars,
23   writeScript,
26 stdenv.mkDerivation rec {
27   pname = "argyllcms";
28   version = "3.3.0";
30   src = fetchzip {
31     # Kind of flacky URL, it was reaturning 406 and inconsistent binaries for a
32     # while on me. It might be good to find a mirror
33     url = "https://www.argyllcms.com/Argyll_V${version}_src.zip";
34     hash = "sha256-xpbj15GzpGS0d1UjzvYiZ1nmmTjNIyv0ST2blmi7ZSk=";
35   };
37   nativeBuildInputs = [
38     jam
39     unzip
40   ];
42   patches = lib.optional (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) (
43     # Build process generates files by compiling and then invoking an executable.
44     replaceVars ./jam-cross.patch {
45       emulator = stdenv.hostPlatform.emulator buildPackages;
46     }
47   );
49   postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
50     substituteInPlace Jambase \
51       --replace "-m64" ""
52   '';
54   preConfigure =
55     let
56       # The contents of this file comes from the Jamtop file from the
57       # root of the ArgyllCMS distribution, rewritten to pick up Nixpkgs
58       # library paths. When ArgyllCMS is updated, make sure that changes
59       # in that file is reflected here.
60       jamTop = writeText "argyllcms_jamtop" ''
61         DESTDIR = "/" ;
62         REFSUBDIR = "share/argyllcms" ;
64         # Keep this DESTDIR anchored to Jamtop. PREFIX is used literally
65         ANCHORED_PATH_VARS = DESTDIR ;
67         # Tell standalone libraries that they are part of Argyll:
68         DEFINES += ARGYLLCMS ;
70         # enable serial instruments & support
71         USE_SERIAL = true ;
73         # enable fast serial instruments & support
74         USE_FAST_SERIAL = true ;                # (Implicit in USE_SERIAL too)
76         # enable USB instruments & support
77         USE_USB = true ;
79         # enable dummy Demo Instrument (only if code is available)
80         USE_DEMOINST = true ;
82         # enable Video Test Patch Generator and 3DLUT device support
83         # (V2.0.0 and above)
84         USE_VTPGLUT = false ;
86         # enable Printer device support
87         USE_PRINTER = false ;
89         # enable CMF Measurement device and accessory support (if present)
90         USE_CMFM = false ;
92         # Use ArgyllCMS version of libusb (deprecated - don't use)
93         USE_LIBUSB = false ;
95         # Compile in graph plotting code (Not fully implemented)
96         USE_PLOT = true ;               # [true]
98         JPEGLIB = ;
99         JPEGINC = ;
100         HAVE_JPEG = true ;
102         TIFFLIB = ;
103         TIFFINC = ;
104         HAVE_TIFF = true ;
106         PNGLIB = ;
107         PNGINC = ;
108         HAVE_PNG = true ;
110         ZLIB = ;
111         ZINC = ;
112         HAVE_Z = true ;
114         SSLLIB = ;
115         SSLINC = ;
116         HAVE_SSL = true ;
118         LINKFLAGS +=
119           ${lib.concatStringsSep " " (map (x: "-L${x}/lib") buildInputs)}
120           -lrt -lX11 -lXext -lXxf86vm -lXinerama -lXrandr -lXau -lXdmcp -lXss
121           -ljpeg -ltiff -lpng -lssl ;
122       '';
123     in
124     ''
125       cp ${jamTop} Jamtop
126       substituteInPlace Makefile --replace "-j 3" "-j $NIX_BUILD_CORES"
127       # Remove tiff, jpg and png to be sure the nixpkgs-provided ones are used
128       rm -rf tiff jpg png
130       export AR="$AR rusc"
131     '';
133   buildInputs = [
134     libtiff
135     libjpeg
136     libpng
137     libX11
138     libXxf86vm
139     libXrandr
140     libXinerama
141     libXext
142     libXrender
143     libXScrnSaver
144     libXdmcp
145     libXau
146     openssl
147   ];
149   buildFlags = [ "all" ];
151   makeFlags = [
152     "PREFIX=${placeholder "out"}"
153   ];
155   # Install udev rules, but remove lines that set up the udev-acl
156   # stuff, since that is handled by udev's own rules (70-udev-acl.rules)
157   postInstall = ''
158     rm -v $out/bin/License.txt
159     mkdir -p $out/etc/udev/rules.d
160     sed -i '/udev-acl/d' usb/55-Argyll.rules
161     cp -v usb/55-Argyll.rules $out/etc/udev/rules.d/
163     sed -i -e 's/^CREATED .*/CREATED "'"$(date -d @$SOURCE_DATE_EPOCH)"'"/g' $out/share/argyllcms/RefMediumGamut.gam
165   '';
167   passthru = {
168     updateScript = writeScript "update-argyllcms" ''
169       #!/usr/bin/env nix-shell
170       #!nix-shell -i bash -p curl pcre common-updater-scripts
172       set -eu -o pipefail
174       # Expect the text in format of 'Current Version 3.0.1 (19th October 2023)'
175       new_version="$(curl -s https://www.argyllcms.com/ |
176           pcregrep -o1 '>Current Version ([0-9.]+) ')"
177       update-source-version ${pname} "$new_version"
178     '';
179   };
181   meta = with lib; {
182     homepage = "https://www.argyllcms.com/";
183     description = "Color management system (compatible with ICC)";
184     license = licenses.gpl3;
185     maintainers = [ ];
186     platforms = platforms.linux;
187   };