Let's give it a try

This commit is contained in:
Benson Chu 2024-06-23 07:53:08 -05:00
parent 0210accc5d
commit 46e5f2ec85
2 changed files with 67 additions and 28 deletions

View file

@ -188,7 +188,7 @@ in
urwid urwid
])) ]))
# (pkgs.callPackage ./mfcl2690dw/default.nix { }) (pkgs.callPackage ./mfcl2690dw/default.nix { })
]; ];
networking.firewall.allowedTCPPorts = [ 22 ]; networking.firewall.allowedTCPPorts = [ 22 ];

View file

@ -1,44 +1,83 @@
{ pkgsi686Linux, lib, stdenv, fetchurl, dpkg, makeWrapper, coreutils, ghostscript, gnugrep, gnused, which, perl }: { 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
];
printerName = "mfcl2690dw";
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "mfcl2690dwpdrv"; pname = "cups-brother-${printerName}";
version = "4.0.0-1"; version = "4.0.0-1";
nativeBuildInputs = [ dpkg makeWrapper autoPatchelfHook ];
buildInputs = [ perl ];
dontUnpack = true;
src = fetchurl { src = fetchurl {
url = "https://download.brother.com/welcome/dlf101727/${pname}-${version}.i386.deb"; url = "https://download.brother.com/welcome/dlf105065/${printerName}pdrv-${version}.i386.deb";
sha256 = "765da49f1f0d68ed36ba553e6e60aa5030e87845b74afe0d7d46ebab28ab5256"; sha256 = "765da49f1f0d68ed36ba553e6e60aa5030e87845b74afe0d7d46ebab28ab5256";
}; };
nativeBuildInputs = [ dpkg makeWrapper ];
unpackPhase = "dpkg-deb -x $src $out";
installPhase = '' installPhase = ''
dir=$out/opt/brother/Printers/MFCL2690DW runHook preInstall
substituteInPlace $dir/lpd/lpdfilter \ mkdir -p $out
--replace /usr/bin/perl ${perl}/bin/perl \ dpkg-deb -x $src $out
--replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$dir\"; #" \
--replace "PRINTER =~" "PRINTER = \"MFCL2690DW\"; #"
wrapProgram $dir/lpd/filter_MFCL2690DW \ # delete unnecessary files for the current architecture
--prefix PATH : ${lib.makeBinPath [ '' + lib.concatMapStrings (arch: ''
coreutils ghostscript gnugrep gnused which echo Deleting files for ${arch}
]} rm -r "$out/opt/brother/Printers/MFCL2690DW/lpd/${arch}"
'') (builtins.filter (arch: arch != stdenv.hostPlatform.linuxArch) arches) + ''
# need to use i686 glibc here, these are 32bit proprietary binaries # bundled scripts don't understand the arch subdirectories for some reason
interpreter=${pkgsi686Linux.glibc}/lib/ld-linux.so.2 ln -s \
patchelf --set-interpreter "$interpreter" $dir/inf/braddprinter "$out/opt/brother/Printers/MFCL2690DW/lpd/${stdenv.hostPlatform.linuxArch}/"* \
patchelf --set-interpreter "$interpreter" $dir/lpd/brprintconflsr3 "$out/opt/brother/Printers/MFCL2690DW/lpd/"
patchelf --set-interpreter "$interpreter" $dir/lpd/rawtobr3
'';
meta = { # Fix global references and replace auto discovery mechanism with hardcoded values
description = "Brother MFC-L2690DW lpr driver"; substituteInPlace $out/opt/brother/Printers/MFCL2690DW/lpd/lpdfilter \
--replace /opt "$out/opt" \
--replace "my \$BR_PRT_PATH =" "my \$BR_PRT_PATH = \"$out/opt/brother/Printers/MFCL2690DW\"; #" \
--replace "PRINTER =~" "PRINTER = \"MFCL2690DW\"; #"
# 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/MFCL2690DW/lpd/lpdfilter \
$out/lib/cups/filter/brother_lpdwrapper_MFCL2690DW
ln -s \
$out/opt/brother/Printers/MFCL2690DW/cupswrapper/brother-MFCL2690DW-cups-en.ppd \
$out/share/cups/model/
runHook postInstall
'';
meta = with lib; {
homepage = "http://www.brother.com/"; homepage = "http://www.brother.com/";
description = "Brother MFC-L2690DW printer driver";
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = lib.licenses.unfree; license = licenses.unfree;
platforms = [ "x86_64-linux" "i686-linux" ]; platforms = builtins.map (arch: "${arch}-linux") arches;
maintainers = [ lib.maintainers.Enzime ]; maintainers = [ maintainers.lovesegfault ];
}; };
} }