From df86bea46f32d1ce698b86841452c7fa63700243 Mon Sep 17 00:00:00 2001 From: u2x1 Date: Wed, 18 Sep 2024 01:03:05 +0800 Subject: [PATCH] cups-brother-dcpt725dw: init at 3.5.0-1 --- .../cu/cups-brother-dcpt725dw/package.nix | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 pkgs/by-name/cu/cups-brother-dcpt725dw/package.nix diff --git a/pkgs/by-name/cu/cups-brother-dcpt725dw/package.nix b/pkgs/by-name/cu/cups-brother-dcpt725dw/package.nix new file mode 100644 index 000000000000..b93e8e1fc32f --- /dev/null +++ b/pkgs/by-name/cu/cups-brother-dcpt725dw/package.nix @@ -0,0 +1,113 @@ +{ + stdenv, + lib, + fetchurl, + perl, + ghostscript, + coreutils, + gnugrep, + which, + file, + gnused, + dpkg, + makeWrapper, + libredirect, + debugLvl ? "0", +}: + +stdenv.mkDerivation rec { + pname = "cups-brother-dcpt725dw"; + version = "3.5.0-1"; + src = fetchurl { + url = "https://download.brother.com/welcome/dlf105181/dcpt725dwpdrv-${version}.i386.deb"; + hash = "sha256-fK6RHaW/ej1nFgSaTbzWxVgjIW32YTbJbd1xD37ZE7c="; + }; + + nativeBuildInputs = [ + dpkg + makeWrapper + ]; + buildInputs = [ perl ]; + + dontUnpack = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out + dpkg-deb -x $src $out + + LPDDIR=$out/opt/brother/Printers/dcpt725dw/lpd + WRAPPER=$out/opt/brother/Printers/dcpt725dw/cupswrapper/brother_lpdwrapper_dcpt725dw + + ln -s $LPDDIR/${stdenv.hostPlatform.linuxArch}/* $LPDDIR/ + + substituteInPlace $WRAPPER \ + --replace-fail "PRINTER =~" "PRINTER = \"dcpt725dw\"; #" \ + --replace-fail "basedir =~" "basedir = \"$out/opt/brother/Printers/dcpt725dw/\"; #" \ + --replace-fail "lpdconf = " "lpdconf = \$lpddir.'/'.\$LPDCONFIGEXE.\$PRINTER; #" \ + --replace-fail "\$DEBUG=0;" "\$DEBUG=${debugLvl};" + + substituteInPlace $LPDDIR/filter_dcpt725dw \ + --replace-fail "BR_PRT_PATH =~" "BR_PRT_PATH = \"$out/opt/brother/Printers/dcpt725dw/\"; #" \ + --replace-fail "PRINTER =~" "PRINTER = \"dcpt725dw\"; #" + + wrapProgram $WRAPPER \ + --prefix PATH : ${ + lib.makeBinPath [ + coreutils + gnugrep + gnused + ] + } + + wrapProgram $LPDDIR/filter_dcpt725dw \ + --prefix PATH : ${ + lib.makeBinPath [ + coreutils + ghostscript + gnugrep + gnused + which + file + ] + } + + patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + $LPDDIR/brdcpt725dwfilter + + patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + $LPDDIR/brprintconf_dcpt725dw + + wrapProgram $LPDDIR/brprintconf_dcpt725dw \ + --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \ + --set NIX_REDIRECTS /opt=$out/opt + + wrapProgram $LPDDIR/brdcpt725dwfilter \ + --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \ + --set NIX_REDIRECTS /opt=$out/opt + + mkdir -p "$out/lib/cups/filter" "$out/share/cups/model" + + ln -s $out/opt/brother/Printers/dcpt725dw/cupswrapper/brother_lpdwrapper_dcpt725dw \ + $out/lib/cups/filter/brother_lpdwrapper_dcpt725dw + + ln -s "$out/opt/brother/Printers/dcpt725dw/cupswrapper/brother_dcpt725dw_printer_en.ppd" \ + "$out/share/cups/model/" + + runHook postInstall + ''; + + meta = with lib; { + description = "Brother DCP-T725DW printer driver"; + license = licenses.unfree; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + maintainers = with maintainers; [ u2x1 ]; + platforms = [ + "x86_64-linux" + "i686-linux" + ]; + downloadPage = "https://support.brother.com/g/b/downloadtop.aspx?c=cn_ot&lang=en&prod=dcpt725dw_cn"; + homepage = "http://www.brother.com/"; + }; +}