From a3cfdf39a7ed654906a8c9e3d1e3f7b1abace5dd Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Wed, 23 Mar 2022 14:40:36 -0700 Subject: [PATCH] cups-brother-mfcl2750dw: init at 4.0.0-1 --- pkgs/misc/cups/drivers/mfcl2750dw/default.nix | 93 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 95 insertions(+) create mode 100644 pkgs/misc/cups/drivers/mfcl2750dw/default.nix diff --git a/pkgs/misc/cups/drivers/mfcl2750dw/default.nix b/pkgs/misc/cups/drivers/mfcl2750dw/default.nix new file mode 100644 index 00000000000..269546aca1a --- /dev/null +++ b/pkgs/misc/cups/drivers/mfcl2750dw/default.nix @@ -0,0 +1,93 @@ +{ lib +, stdenv +, fetchurl +, dpkg +, autoPatchelfHook +, makeWrapper +, perl +, gnused +, ghostscript +, file +, coreutils +, gnugrep +, which +}: + +let + arches = [ "x86_64" "i686" "armv7l" ]; + + runtimeDeps = [ + ghostscript + file + gnused + gnugrep + coreutils + which + ]; +in + +stdenv.mkDerivation rec { + pname = "cups-brother-mfcl2750dw"; + version = "4.0.0-1"; + + nativeBuildInputs = [ dpkg makeWrapper autoPatchelfHook ]; + buildInputs = [ perl ]; + + dontUnpack = true; + + src = fetchurl { + url = "https://download.brother.com/welcome/dlf103566/mfcl2750dwpdrv-${version}.i386.deb"; + hash = "sha256-3uDwzLQTF8r1tsGZ7ChGhk4ryQmVsZYdUaj9eFaC0jc="; + }; + + installPhase = '' + runHook preInstall + + mkdir -p $out + dpkg-deb -x $src $out + + # delete unnecessary files for the current architecture + '' + lib.concatMapStrings (arch: '' + echo Deleting files for ${arch} + rm -r "$out/opt/brother/Printers/MFCL2750DW/lpd/${arch}" + '') (builtins.filter (arch: arch != stdenv.hostPlatform.linuxArch) arches) + '' + + # bundled scripts don't understand the arch subdirectories for some reason + ln -s \ + "$out/opt/brother/Printers/MFCL2750DW/lpd/${stdenv.hostPlatform.linuxArch}/"* \ + "$out/opt/brother/Printers/MFCL2750DW/lpd/" + + # Fix global references and replace auto discovery mechanism with hardcoded values + substituteInPlace $out/opt/brother/Printers/MFCL2750DW/lpd/lpdfilter \ + --replace /opt "$out/opt" \ + --replace "my \$BR_PRT_PATH =" "my \$BR_PRT_PATH = \"$out/opt/brother/Printers/MFCL2750DW\"; #" \ + --replace "PRINTER =~" "PRINTER = \"MFCL2750DW\"; #" + + # Make sure all executables have the necessary runtime dependencies available + find "$out" -executable -and -type f | while read file; do + wrapProgram "$file" --prefix PATH : "${lib.makeBinPath runtimeDeps}" + done + + # Symlink filter and ppd into a location where CUPS will discover it + mkdir -p $out/lib/cups/filter + mkdir -p $out/share/cups/model + + ln -s \ + $out/opt/brother/Printers/MFCL2750DW/lpd/lpdfilter \ + $out/lib/cups/filter/brother_lpdwrapper_MFCL2750DW + + ln -s \ + $out/opt/brother/Printers/MFCL2750DW/cupswrapper/brother-MFCL2750DW-cups-en.ppd \ + $out/share/cups/model/ + + runHook postInstall + ''; + + meta = with lib; { + homepage = "http://www.brother.com/"; + description = "Brother MFC-L2750DW printer driver"; + license = licenses.unfree; + platforms = builtins.map (arch: "${arch}-linux") arches; + maintainers = [ maintainers.lovesegfault ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a7e14257e94..6cd9a82af08 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -33277,6 +33277,8 @@ with pkgs; cups-brother-hll2350dw = callPackage ../misc/cups/drivers/hll2350dw { }; + cups-brother-mfcl2750dw = callPackage ../misc/cups/drivers/mfcl2750dw { }; + cups-drv-rastertosag-gdi = callPackage ../misc/cups/drivers/cups-drv-rastertosag-gdi { }; # this driver ships with pre-compiled 32-bit binary libraries