29 if stdenv.hostPlatform.system == "x86_64-linux" then "intel"
30 else if stdenv.hostPlatform.system == "aarch64-linux" then "arm"
31 else throw "Unsupported platform for Canon UFR2 Drivers: ${stdenv.hostPlatform.system}";
32 ld64 = "${stdenv.cc}/nix-support/dynamic-linker";
33 libs = pkgs: lib.makeLibraryPath buildInputs;
36 dl = "0/0100009240/34";
40 versionNoDots = builtins.replaceStrings [ "." ] [ "" ] version;
41 src_canon = fetchurl {
42 url = "http://gdlp01.c-wss.com/gds/${dl}/linux-UFRII-drv-v${versionNoDots}-${suffix1}-${suffix2}.tar.gz";
43 hash = "sha256-JQAe/avYG+9TAsH26UGai6u8/upRXwZrGBc/hd4jZe8=";
46 buildInputs = [ cups zlib jbigkit libjpeg libgcrypt glib gtk3 libxml2 gdk-pixbuf pango cairo atk ];
48 stdenv.mkDerivation rec {
49 pname = "canon-cups-ufr2";
53 # we can't let patchelf remove unnecessary RPATHs because the driver uses dlopen to load libjpeg and libgcrypt
59 tar -xf Sources/cnrdrvcups-lb-${version}-1.${suffix2}.tar.xz
60 sed -ie "s@_prefix=/usr@_prefix=$out@" cnrdrvcups-common-${version}/allgen.sh
61 sed -ie "s@_libdir=/usr/lib@_libdir=$out/lib@" cnrdrvcups-common-${version}/allgen.sh
62 sed -ie "s@_bindir=/usr/bin@_bindir=$out/bin@" cnrdrvcups-common-${version}/allgen.sh
63 sed -ie "s@/usr@$out@" cnrdrvcups-common-${version}/{{backend,rasterfilter}/Makefile.am,rasterfilter/cnrasterproc.h}
64 sed -ie "s@etc/cngplp@$out/etc/cngplp@" cnrdrvcups-common-${version}/cngplp/Makefile.am
65 sed -ie "s@usr/share/cngplp@$out/usr/share/cngplp@" cnrdrvcups-common-${version}/cngplp/src/Makefile.am
66 patchShebangs cnrdrvcups-common-${version}
68 sed -ie "s@_prefix=/usr@_prefix=$out@" cnrdrvcups-lb-${version}/allgen.sh
69 sed -ie "s@_libdir=/usr/lib@_libdir=$out/lib@" cnrdrvcups-lb-${version}/allgen.sh
70 sed -ie "s@_bindir=/usr/bin@_bindir=$out/bin@" cnrdrvcups-lb-${version}/allgen.sh
71 sed -ie '/^cd \.\.\/cngplp/,/^cd files/{/^cd files/!{d}}' cnrdrvcups-lb-${version}/allgen.sh
72 sed -ie "s@cd \.\./pdftocpca@cd pdftocpca@" cnrdrvcups-lb-${version}/allgen.sh
73 sed -ie "s@/usr@$out@" cnrdrvcups-lb-${version}/pdftocpca/Makefile.am
74 sed -i "/CNGPLPDIR/d" cnrdrvcups-lb-${version}/Makefile
75 patchShebangs cnrdrvcups-lb-${version}
79 nativeBuildInputs = [ makeWrapper unzip autoconf automake libtool_1_5 pkg-config ];
87 cd cnrdrvcups-common-${version}
92 cd cnrdrvcups-common-${version}/Rule
93 mkdir -p $out/share/cups/usb
94 install -m 644 *.usb-quirks $out/share/cups/usb
97 cd cnrdrvcups-lb-${version}
101 mkdir -p $out/share/cups/model
102 install -m 644 ppd/*.ppd $out/share/cups/model/
108 install -m 755 libs64/${system}/libColorGearCufr2.so.2.0.0 $out/lib
109 install -m 755 libs64/${system}/libcaepcmufr2.so.1.0 $out/lib
110 install -m 755 libs64/${system}/libcaiocnpkbidir.so.1.0.0 $out/lib
111 install -m 755 libs64/${system}/libcaiousb.so.1.0.0 $out/lib
112 install -m 755 libs64/${system}/libcaiowrapufr2.so.1.0.0 $out/lib
113 install -m 755 libs64/${system}/libcanon_slimufr2.so.1.0.0 $out/lib
114 install -m 755 libs64/${system}/libcanonufr2r.so.1.0.0 $out/lib
115 install -m 755 libs64/${system}/libcnaccm.so.1.0 $out/lib
116 install -m 755 libs64/${system}/libcnlbcmr.so.1.0 $out/lib
117 install -m 755 libs64/${system}/libcnncapcmr.so.1.0 $out/lib
118 install -m 755 libs64/${system}/libufr2filterr.so.1.0.0 $out/lib
120 install -m 755 libs64/${system}/cnpdfdrv $out/bin
121 install -m 755 libs64/${system}/cnpkbidir $out/bin
122 install -m 755 libs64/${system}/cnpkmoduleufr2r $out/bin
123 install -m 755 libs64/${system}/cnrsdrvufr2 $out/bin
124 install -m 755 libs64/${system}/cnsetuputil2 $out/bin/cnsetuputil2
126 mkdir -p $out/share/cnpkbidir
127 install -m 644 libs64/${system}/cnpkbidir_info* $out/share/cnpkbidir
129 mkdir -p $out/share/ufr2filter
130 install -m 644 libs64/${system}/ThLB* $out/share/ufr2filter
136 ln -sf libColorGearCufr2.so.2.0.0 libColorGearCufr2.so
137 ln -sf libColorGearCufr2.so.2.0.0 libColorGearCufr2.so.2
138 ln -sf libcaepcmufr2.so.1.0 libcaepcmufr2.so
139 ln -sf libcaepcmufr2.so.1.0 libcaepcmufr2.so.1
140 ln -sf libcaiocnpkbidir.so.1.0.0 libcaiocnpkbidir.so
141 ln -sf libcaiocnpkbidir.so.1.0.0 libcaiocnpkbidir.so.1
142 ln -sf libcaiowrapufr2.so.1.0.0 libcaiowrapufr2.so
143 ln -sf libcaiowrapufr2.so.1.0.0 libcaiowrapufr2.so.1
144 ln -sf libcanon_slimufr2.so.1.0.0 libcanon_slimufr2.so
145 ln -sf libcanon_slimufr2.so.1.0.0 libcanon_slimufr2.so.1
146 ln -sf libcanonufr2r.so.1.0.0 libcanonufr2r.so
147 ln -sf libcanonufr2r.so.1.0.0 libcanonufr2r.so.1
148 ln -sf libcnlbcmr.so.1.0 libcnlbcmr.so
149 ln -sf libcnlbcmr.so.1.0 libcnlbcmr.so.1
150 ln -sf libufr2filterr.so.1.0.0 libufr2filterr.so
151 ln -sf libufr2filterr.so.1.0.0 libufr2filterr.so.1
152 ln -sf libuictlufr2r.so.1.0.0 libuictlufr2r.so
153 ln -sf libuictlufr2r.so.1.0.0 libuictlufr2r.so.1
155 patchelf --set-rpath "$(cat $NIX_CC/nix-support/orig-cc)/lib:${libs pkgs}:${lib.getLib stdenv.cc.cc}/lib64:${stdenv.cc.libc}/lib64:$out/lib" libcanonufr2r.so.1.0.0
156 patchelf --set-rpath "$(cat $NIX_CC/nix-support/orig-cc)/lib:${libs pkgs}:${lib.getLib stdenv.cc.cc}/lib64:${stdenv.cc.libc}/lib64" libcaepcmufr2.so.1.0
157 patchelf --set-rpath "$(cat $NIX_CC/nix-support/orig-cc)/lib:${libs pkgs}:${lib.getLib stdenv.cc.cc}/lib64:${stdenv.cc.libc}/lib64" libColorGearCufr2.so.2.0.0
162 patchelf --set-interpreter "$(cat ${ld64})" --set-rpath "${lib.makeLibraryPath buildInputs}:${lib.getLib stdenv.cc.cc}/lib64:${stdenv.cc.libc}/lib64" cnsetuputil2 cnpdfdrv
163 patchelf --set-interpreter "$(cat ${ld64})" --set-rpath "${lib.makeLibraryPath buildInputs}:${lib.getLib stdenv.cc.cc}/lib64:${stdenv.cc.libc}/lib64:$out/lib" cnpkbidir cnrsdrvufr2 cnpkmoduleufr2r cnjbigufr2
165 wrapProgram $out/bin/cnrsdrvufr2 \
166 --prefix LD_LIBRARY_PATH ":" "$out/lib" \
167 --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
168 --set NIX_REDIRECTS /usr/bin/cnpkmoduleufr2r=$out/bin/cnpkmoduleufr2r:/usr/bin/cnjbigufr2=$out/bin/cnjbigufr2
170 wrapProgram $out/bin/cnsetuputil2 \
171 --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
172 --set NIX_REDIRECTS /usr/share/cnsetuputil2=$out/usr/share/cnsetuputil2
177 mkdir -p $out/share/caepcm
178 install -m 644 *.ICC $out/share/caepcm
179 install -m 644 *.icc $out/share/caepcm
180 install -m 644 *.PRF $out/share/caepcm
181 install -m 644 CnLB* $out/share/caepcm
185 cd cnrdrvcups-utility-${version}/data
186 mkdir -p $out/usr/share/cnsetuputil2
187 install -m 644 cnsetuputil* $out/usr/share/cnsetuputil2
190 makeWrapper "${ghostscript}/bin/gs" "$out/bin/gs" \
191 --prefix LD_LIBRARY_PATH ":" "$out/lib" \
192 --prefix PATH ":" "$out/bin"
198 description = "CUPS Linux drivers for Canon printers";
199 homepage = "http://www.canon.com/";
200 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
201 license = licenses.unfree;
202 maintainers = with maintainers; [ lluchs ];