27 if stdenv.hostPlatform.system == "x86_64-linux" then "intel"
28 else if stdenv.hostPlatform.system == "aarch64-linux" then "arm"
29 else throw "Unsupported platform for Canon UFR2 Drivers: ${stdenv.hostPlatform.system}";
30 ld64 = "${stdenv.cc}/nix-support/dynamic-linker";
31 libs = pkgs: lib.makeLibraryPath buildInputs;
34 dl = "8/0100007658/40";
38 versionNoDots = builtins.replaceStrings [ "." ] [ "" ] version;
39 src_canon = fetchurl {
40 url = "http://gdlp01.c-wss.com/gds/${dl}/linux-UFRII-drv-v${versionNoDots}-${suffix1}-${suffix2}.tar.gz";
41 hash = "sha256-HvuRQYqkHRCwfajSJPridDcADq7VkYwBEo4qr9W5mqA=";
44 buildInputs = [ cups zlib jbigkit glib gtk3 libxml2 gdk-pixbuf pango cairo atk ];
46 stdenv.mkDerivation rec {
47 pname = "canon-cups-ufr2";
54 tar -xf Sources/cnrdrvcups-lb-${version}-1.${suffix2}.tar.xz
55 sed -ie "s@_prefix=/usr@_prefix=$out@" cnrdrvcups-common-${version}/allgen.sh
56 sed -ie "s@_libdir=/usr/lib@_libdir=$out/lib@" cnrdrvcups-common-${version}/allgen.sh
57 sed -ie "s@_bindir=/usr/bin@_bindir=$out/bin@" cnrdrvcups-common-${version}/allgen.sh
58 sed -ie "s@/usr@$out@" cnrdrvcups-common-${version}/{{backend,rasterfilter}/Makefile.am,rasterfilter/cnrasterproc.h}
59 sed -ie "s@etc/cngplp@$out/etc/cngplp@" cnrdrvcups-common-${version}/cngplp/Makefile.am
60 sed -ie "s@usr/share/cngplp@$out/usr/share/cngplp@" cnrdrvcups-common-${version}/cngplp/src/Makefile.am
61 patchShebangs cnrdrvcups-common-${version}
63 sed -ie "s@_prefix=/usr@_prefix=$out@" cnrdrvcups-lb-${version}/allgen.sh
64 sed -ie "s@_libdir=/usr/lib@_libdir=$out/lib@" cnrdrvcups-lb-${version}/allgen.sh
65 sed -ie "s@_bindir=/usr/bin@_bindir=$out/bin@" cnrdrvcups-lb-${version}/allgen.sh
66 sed -ie '/^cd \.\.\/cngplp/,/^cd files/{/^cd files/!{d}}' cnrdrvcups-lb-${version}/allgen.sh
67 sed -ie "s@cd \.\./pdftocpca@cd pdftocpca@" cnrdrvcups-lb-${version}/allgen.sh
68 sed -ie "s@/usr@$out@" cnrdrvcups-lb-${version}/pdftocpca/Makefile.am
69 sed -i "/CNGPLPDIR/d" cnrdrvcups-lb-${version}/Makefile
70 patchShebangs cnrdrvcups-lb-${version}
74 nativeBuildInputs = [ makeWrapper unzip autoconf automake libtool_1_5 pkg-config ];
82 cd cnrdrvcups-common-${version}
87 cd cnrdrvcups-common-${version}/Rule
88 mkdir -p $out/share/cups/usb
89 install -m 644 *.usb-quirks $out/share/cups/usb
92 cd cnrdrvcups-lb-${version}
96 mkdir -p $out/share/cups/model
97 install -m 644 ppd/*.ppd $out/share/cups/model/
103 install -m 755 libs64/${system}/libColorGearCufr2.so.2.0.0 $out/lib
104 install -m 755 libs64/${system}/libcaepcmufr2.so.1.0 $out/lib
105 install -m 755 libs64/${system}/libcaiocnpkbidir.so.1.0.0 $out/lib
106 install -m 755 libs64/${system}/libcaiousb.so.1.0.0 $out/lib
107 install -m 755 libs64/${system}/libcaiowrapufr2.so.1.0.0 $out/lib
108 install -m 755 libs64/${system}/libcanon_slimufr2.so.1.0.0 $out/lib
109 install -m 755 libs64/${system}/libcanonufr2r.so.1.0.0 $out/lib
110 install -m 755 libs64/${system}/libcnaccm.so.1.0 $out/lib
111 install -m 755 libs64/${system}/libcnlbcmr.so.1.0 $out/lib
112 install -m 755 libs64/${system}/libcnncapcmr.so.1.0 $out/lib
113 install -m 755 libs64/${system}/libufr2filterr.so.1.0.0 $out/lib
115 install -m 755 libs64/${system}/cnpdfdrv $out/bin
116 install -m 755 libs64/${system}/cnpkbidir $out/bin
117 install -m 755 libs64/${system}/cnpkmoduleufr2r $out/bin
118 install -m 755 libs64/${system}/cnrsdrvufr2 $out/bin
119 install -m 755 libs64/${system}/cnsetuputil2 $out/bin/cnsetuputil2
121 mkdir -p $out/share/cnpkbidir
122 install -m 644 libs64/${system}/cnpkbidir_info* $out/share/cnpkbidir
124 mkdir -p $out/share/ufr2filter
125 install -m 644 libs64/${system}/ThLB* $out/share/ufr2filter
131 ln -sf libColorGearCufr2.so.2.0.0 libColorGearCufr2.so
132 ln -sf libColorGearCufr2.so.2.0.0 libColorGearCufr2.so.2
133 ln -sf libcaepcmufr2.so.1.0 libcaepcmufr2.so
134 ln -sf libcaepcmufr2.so.1.0 libcaepcmufr2.so.1
135 ln -sf libcaiocnpkbidir.so.1.0.0 libcaiocnpkbidir.so
136 ln -sf libcaiocnpkbidir.so.1.0.0 libcaiocnpkbidir.so.1
137 ln -sf libcaiowrapufr2.so.1.0.0 libcaiowrapufr2.so
138 ln -sf libcaiowrapufr2.so.1.0.0 libcaiowrapufr2.so.1
139 ln -sf libcanon_slimufr2.so.1.0.0 libcanon_slimufr2.so
140 ln -sf libcanon_slimufr2.so.1.0.0 libcanon_slimufr2.so.1
141 ln -sf libcanonufr2r.so.1.0.0 libcanonufr2r.so
142 ln -sf libcanonufr2r.so.1.0.0 libcanonufr2r.so.1
143 ln -sf libcnlbcmr.so.1.0 libcnlbcmr.so
144 ln -sf libcnlbcmr.so.1.0 libcnlbcmr.so.1
145 ln -sf libufr2filterr.so.1.0.0 libufr2filterr.so
146 ln -sf libufr2filterr.so.1.0.0 libufr2filterr.so.1
147 ln -sf libuictlufr2r.so.1.0.0 libuictlufr2r.so
148 ln -sf libuictlufr2r.so.1.0.0 libuictlufr2r.so.1
150 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
151 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
152 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
157 patchelf --set-interpreter "$(cat ${ld64})" --set-rpath "${lib.makeLibraryPath buildInputs}:${lib.getLib stdenv.cc.cc}/lib64:${stdenv.cc.libc}/lib64" cnsetuputil2 cnpdfdrv
158 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
160 wrapProgram $out/bin/cnrsdrvufr2 \
161 --prefix LD_LIBRARY_PATH ":" "$out/lib" \
162 --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
163 --set NIX_REDIRECTS /usr/bin/cnpkmoduleufr2r=$out/bin/cnpkmoduleufr2r:/usr/bin/cnjbigufr2=$out/bin/cnjbigufr2
165 wrapProgram $out/bin/cnsetuputil2 \
166 --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
167 --set NIX_REDIRECTS /usr/share/cnsetuputil2=$out/usr/share/cnsetuputil2
172 mkdir -p $out/share/caepcm
173 install -m 644 *.ICC $out/share/caepcm
174 install -m 644 *.icc $out/share/caepcm
175 install -m 644 *.PRF $out/share/caepcm
176 install -m 644 CnLB* $out/share/caepcm
180 cd cnrdrvcups-utility-${version}/data
181 mkdir -p $out/usr/share/cnsetuputil2
182 install -m 644 cnsetuputil* $out/usr/share/cnsetuputil2
185 makeWrapper "${ghostscript}/bin/gs" "$out/bin/gs" \
186 --prefix LD_LIBRARY_PATH ":" "$out/lib" \
187 --prefix PATH ":" "$out/bin"
193 description = "CUPS Linux drivers for Canon printers";
194 homepage = "http://www.canon.com/";
195 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
196 license = licenses.unfree;
197 maintainers = with maintainers; [ lluchs ];