{ lib , stdenv , fetchurl , makeWrapper , cups , dpkg , a2ps , ghostscript , gnugrep , gnused , coreutils , file , perl , which }: stdenv.mkDerivation rec { pname = "dcpl2530dw-cups"; version = "4.0.0"; src = fetchurl { # The i386 part is a lie. There are x86, x86_64 and armv7l drivers. # Though this builds only supports x86_64 for now. url = "https://download.brother.com/welcome/dlf103518/dcpl2530dwpdrv-${version}-1.i386.deb"; sha256 = "sha256-f5lxwp7iu6gvmP7DU3xQMH8rOcuUT0vlxVTUiTg1eeo="; }; nativeBuildInputs = [ makeWrapper ]; buildInputs = [ cups ghostscript dpkg a2ps ]; dontUnpack = true; installPhase = '' dpkg-deb -x $src $out substituteInPlace $out/opt/brother/Printers/DCPL2530DW/lpd/lpdfilter \ --replace /opt "$out/opt" \ --replace /usr/bin/perl ${perl}/bin/perl \ --replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$out\"; #" \ --replace "PRINTER =~" "PRINTER = \"DCPL2530DW\"; #" # FIXME : Allow i686 and armv7l variations to be setup instead. _PLAT=x86_64 patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ $out/opt/brother/Printers/DCPL2530DW/lpd/$_PLAT/brprintconflsr3 patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ $out/opt/brother/Printers/DCPL2530DW/lpd/$_PLAT/rawtobr3 ln -s $out/opt/brother/Printers/DCPL2530DW/lpd/$_PLAT/brprintconflsr3 $out/opt/brother/Printers/DCPL2530DW/lpd/brprintconflsr3 ln -s $out/opt/brother/Printers/DCPL2530DW/lpd/$_PLAT/rawtobr3 $out/opt/brother/Printers/DCPL2530DW/lpd/rawtobr3 for f in \ $out/opt/brother/Printers/DCPL2530DW/cupswrapper/lpdwrapper \ $out/opt/brother/Printers/DCPL2530DW/cupswrapper/paperconfigml2 \ ; do #substituteInPlace $f \ wrapProgram $f \ --prefix PATH : ${lib.makeBinPath [ coreutils ghostscript gnugrep gnused ]} done mkdir -p $out/lib/cups/filter/ ln -s $out/opt/brother/Printers/DCPL2530DW/lpd/lpdfilter $out/lib/cups/filter/brother_lpdwrapper_DCPL2530DW mkdir -p $out/share/cups/model ln -s $out/opt/brother/Printers/DCPL2530DW/cupswrapper/brother-DCPL2530DW-cups-en.ppd $out/share/cups/model/ wrapProgram $out/opt/brother/Printers/DCPL2530DW/lpd/lpdfilter \ --prefix PATH ":" ${ lib.makeBinPath [ ghostscript a2ps file gnused gnugrep coreutils which ] } ''; meta = with lib; { homepage = "http://www.brother.com/"; description = "Brother DCP-L2530DW combined print driver"; sourceProvenance = with sourceTypes; [ binaryNativeCode ]; license = licenses.unfree; platforms = [ "x86_64-linux" ]; downloadPage = "https://www.brother.de/support/dcp-l2530dw/downloads"; }; }