Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 87 lines 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 rpm, 6 cpio, 7 zlib, 8}: 9 10/* 11 usage: (sorry, its still impure but works!) 12 13 impure directory: 14 mkdir /opt/gutenprint; sudo cp -r $(nix-build -A gutenprintBin -f $NIXPGS_ALL) /opt/gutenprint 15 16 add the following lines to bindirCmds property of printing/cupsd.nix: 17 18 ln -s ${pkgs.gutenprintBin}/lib/cups/backend/* $out/lib/cups/backend/ 19 ln -s ${pkgs.gutenprintBin}/lib/cups/filter/* $out/lib/cups/filter/ 20 mkdir -p $out/lib/cups/model 21 cat ${pkgs.gutenprintBin}/ppds/Canon/Canon-PIXMA_iP4000-gutenprint.5.0.sim-en.ppd.gz |gunzip > $out/lib/cups/model/Canon-PIXMA_iP4000-gutenprint.5.0.sim-en.ppd 22 sed -i 's@/opt/gutenprint/cups@${pkgs.gutenprintBin}/cups@' $out/lib/cups/model/Canon-PIXMA_iP4000-gutenprint.5.0.sim-en.ppd 23 24 Then rebuild your system and add your printer using the the localhost:603 cups web interface 25 select the extracted .ppd file which can be found in the model directory of 26 sed -n 's/^ServerBin //p' $(sed -n 's/respawn.*-c \(.*''\) -F.*''/\1/p' /etc/event.d/cupsd) 27 (sorry, cups still doesn't see it. You could copy it into /nix/store/ 28 *-cups/lib/cups/model/ and you would be able to select canon -> PIXMA 4000 29 then. I've tried that. 30 31 TODO tidy this all up. Find source instead of binary. Fix paths ... Find out how to check ink levels etc 32*/ 33 34stdenv.mkDerivation { 35 pname = "cups-gutenprint-binary"; 36 version = "5.0.1"; 37 38 src = 39 if stdenv.hostPlatform.system == "x86_64-linux" then 40 fetchurl { 41 url = "https://www.openprinting.org/download/printdriver/debian/dists/lsb3.1/main/binary-amd64/gutenprint_5.0.1-1lsb3.1_amd64.deb"; 42 sha256 = "0an5gba6r6v54r53s2gj2fjk8fzpl4lrksjas2333528b0k8gbbc"; 43 } 44 else 45 throw "TODO"; # get from openprint.com -> drivers -> gutenprint 46 47 buildInputs = [ 48 rpm 49 cpio 50 ]; 51 52 dontUnpack = true; 53 dontInstall = true; 54 dontFixup = true; 55 56 libPath = lib.makeLibraryPath [ 57 stdenv.cc.cc 58 zlib 59 ]; 60 61 buildPhase = '' 62 ar -x $src data.tar.gz 63 tar xfz data.tar.gz 64 cp -r opt/gutenprint $out 65 66 for p in \ 67 $out/cups/lib/driver/gutenprint.5.0 \ 68 $out/bin/{escputil,cups-calibrate} \ 69 $out/cups/lib/driver/gutenprint.5.0 \ 70 $out/cups/lib/filter/{rastertogutenprint.5.0,commandtocanon,commandtoepson} \ 71 $out/cups/lib/backend/{canon,epson} \ 72 $out/sbin/cups-genppd.5.0 \ 73 ; do 74 patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 75 --set-rpath $libPath $p 76 done 77 78 mkdir $out/lib 79 ln -s $out/cups/lib $out/lib/cups 80 ''; 81 82 meta = { 83 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 84 description = "Some additional CUPS drivers including Canon drivers"; 85 platforms = [ "x86_64-linux" ]; 86 }; 87}